/*
 * @(#)P2Piki.java 0.0.1-SNAPSHOT
 *
 * Copyright Group B
 */
package grupb.upf.gui;

import grupb.upf.XMLObjects.Photo;
import grupb.upf.XMLObjects.New;
import grupb.upf.XMLObjects.Video;
import grupb.upf.Controller.Controller;
import grupb.upf.ms.DescriptionContent;
import grupb.upf.ms.SearchProfile;
import grupb.upf.ms.Content;
import grupb.upf.ms.UserContent;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileSystemView;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <p>This is the GUI of the application.</p>
 *
 * @version    0.0.1-SNAPSHOT
 * @author Group B
 */
public final class P2Piki extends javax.swing.JFrame {

    /**
     * The logger. A new logger <code>grupb.upf.gui.P2Piki</code>
     * is created to add the logs of this p2pikiGUI
     */
    private static final Log LOG = LogFactory.getLog(P2Piki.class);
    /**
     * The controller of the application.
     */
    private Controller controller;
    /**
     * True if we are logged and false if not.
     */
    private boolean isLogin = false;
    /**
     * If there are an error connection it will be true.
     */
    private boolean connectionError = false;
    /**
     * List of object results.
     */
    private List < DescriptionContent > results = new Vector();
    /**
     * The model of the table of results.
     */
    private SearchTableModel searchTableModel = new SearchTableModel();
    /**
     * The model of the table of results.
     */
    private NewsTableModel newsTableModel = new NewsTableModel();
    /**
     * The list selection model of the table of results.
     */
    private ListSelectionModel lm;
    /**
     * The list of connected friends.
     */
    private FriendsListModel friendsModel = new FriendsListModel();
    /**
     * The list of title results.
     */
    private boolean quickSearchPanelVisible = true;
    /**
     * True if the panel is visible.
     */
    private boolean friendsPanelVisible = true;
    /**
     * True if the panel is visible.
     */
    private boolean chatPanelVisible = true;
    /**
     * String to save my account name.
     */
    private String me;
    /**
     * The list of instantMessaging windows openned.
     */
    private List < InstantMessageFrame > imList = new Vector();
    /**
     * The list of ListExplorers.
     */
    private List < ListExplorer> listExplorerList = new Vector();
    /**
     * The list of TreeExplorers.
     */
    private List < TreeExplorer > treeExplorerList = new Vector();
    /**
     * The list of Taxonomies with its list of tags.
     */
    private List < List > taxonomies;
    /**
     * The photo panel editor.
     */
    private PhotoPanel photoEdition;
    /**
     * The video panel editor.
     */
    private VideoEditor videoEdition;
    /**
     * The new panel editor.
     */
    private NewsEditor newEdition;
    /**
     * The new panel viewer.
     */
    private NewsViewer newViewer;

    /**
     * Constructor of the class.
     */
    public P2Piki(final Controller guiController) {
        this.controller = guiController;
        lookAndFeel();
        initComponents();
        this.setLocationRelativeTo(null);
        datePanel.setVisible(false);
        advancedPhotoSearchComboBox.setVisible(false);
        newFiltersLabel.setVisible(false);
        initResults();
        initExplorers();
        initListModel();
        initCategories();
        initNews();
    }

    /**
     * Method to set up the look and feel.
     */
    private void lookAndFeel() {
        try {
            UIManager.setLookAndFeel(
                    "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (Exception ex) {
            LOG.fatal("Error setting up look and feel", ex);
        }
    }

    /**
     * Method to init the categories.
     */
    private void initCategories() {
        //Ya tenemos los resultados
        taxonomies = controller.getTaxonomies();
        List tax;
        categoriesComboBox.removeAllItems();
        categoriesComboBox.addItem("------- Choose a category -------");
        for (int i = 0; i < taxonomies.size(); i++) {
            tax = taxonomies.get(i);
            categoriesComboBox.addItem((String) tax.get(0));
        }
        photoEdition.initCategories(taxonomies);
        videoEdition.initCategories(taxonomies);
        newEdition.initCategories(taxonomies);
    }
    /**
     * Method to init the news list.
     */
    public void initNews() {
        newsTableModel = new NewsTableModel();
        newsTable.setModel(newsTableModel);
        List news = controller.getNews();
        if (news != null) {
            for (int i = 0; i < news.size(); i++) {
                newsTableModel.addNew((New) news.get(i));
            }
        }
    }
    /**
     * Method to init the trees.
     */
    private void initExplorers() {
        newEdition = new NewsEditor(this);
        newEdition.setVisible(false);
        newViewer = new NewsViewer(this);
        newViewer.setVisible(false);
        photoEdition = new PhotoPanel(this);
        photoEdition.setVisible(false);
        newsManagerPanel.add(newEdition);
        newsManagerPanel.add(newViewer);
        videoEdition = new VideoEditor(this);
        videoEdition.setVisible(false);
        ListExplorer photoList = new ListExplorer(this, 0);
        photosPanel.add(photoList);
        photosPanel.add(photoEdition);
        listExplorerList.add(photoList);
        ListExplorer videoList = new ListExplorer(this, 1);
        videosPanel.add(videoList);
        videosPanel.add(videoEdition);
        listExplorerList.add(videoList);
        TreeExplorer photoTree = new TreeExplorer(this, 0);
        treeExplorerList.add(photoTree);
        photosDirectoriesTabbedPane.addTab("Local", photoTree);
        TreeExplorer videoTree = new TreeExplorer(this, 1);
        treeExplorerList.add(videoTree);
        videoTreePanel.add(videoTree);
        this.repaint();
    }

    public void updateTreeExplorer(final int type) {
        TreeExplorer treeExplorer = treeExplorerList.get(type);
        treeExplorer = new TreeExplorer(this, type);
        treeExplorerList.set(type, treeExplorer);
    }
    /**
     * Method to add an element to the list.
     * @param f the file to add
     */
    public void listExplorerAddElement(final int type, File f) {
        ((ListExplorer) listExplorerList.get(type)).addElement(f);
    }

    /**
     * Method to remove the elements of the list.
     */
    public void listExplorerRemoveAllElements(final int type) {
        ((ListExplorer) listExplorerList.get(type)).removeAllElements();
    }

    public void directorySelected(final int type, final File f) {
        ((TreeExplorer) treeExplorerList.get(type)).directorySelected(f);
    }

    /**
     * Method to add a result to the search.
     * @param dc the description of the SearchResult received
     */
    public void addResult(final DescriptionContent dc) {
        results = new Vector();
        for (int i = 0; i < searchTableModel.getRowCount(); i++) {
            results.add(searchTableModel.getResult(i));
        }
        results.add(dc);
        searchTableModel = new SearchTableModel();
        searchResultsTable.setModel(searchTableModel);
        searchResultsTable.setSelectionMode(
                ListSelectionModel.SINGLE_SELECTION);
        for (int i = 0; i < results.size(); i++) {
            searchTableModel.addResult((DescriptionContent) results.get(i));
        }
    }

    /**
     * Method to init the results table.
     */
    private void initResults() {
        results = new Vector();
        searchTableModel = new SearchTableModel();
        searchResultsTable.setModel(searchTableModel);
        searchResultsTable.setSelectionMode(
                ListSelectionModel.SINGLE_SELECTION);
    }

    /**
     * Method to init the model of the results table.
     */
    private void initListModel() {
        lm = searchResultsTable.getSelectionModel();
        lm.addListSelectionListener(new ListSelectionListener() {

            /**
             * Listener to catch when a element has been selected.
             */
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (searchResultsTable.getSelectedRow() != -1) {
                    final int index = searchResultsTable
                            .convertRowIndexToModel(
                            searchResultsTable.getSelectedRow());
                    DescriptionContent dc = searchTableModel.getResult(index);
                    if (((String) dc.getProperty("from"))
                            .equalsIgnoreCase("me")
                            || !(dc.getProperty("properties") instanceof Photo)) {
                        downloadButton.setText("View");
                    } else {
                        downloadButton.setText("Download");
                    }
                    if (dc.getProperty("properties") instanceof Photo) {
                        ImageIcon icon = (ImageIcon)
                                dc.getProperty("thumbnail");
                        imageLabel.setIcon(icon);
                    } else {
                        imageLabel.setIcon(null);
                    }
                }
            }
        });
    }
    /**
     * Method to send an instant message to another user.
     * @param msg the message
     * @param to the opponent
     */
    public void sendInstantMessage(final String msg, final String to) {
        controller.sendInstantMessage(msg, to);
    }
    /**
     * Method to receive instantMessages.
     * @param msg the message
     * @param from the opponent
     */
    public void instantMessageReceived(final String msg, final String from) {
        boolean isCreated = false;
        for (int i = 0; i < imList.size(); i++) {
            InstantMessageFrame aux = imList.get(i);
            if (aux.getTo().equalsIgnoreCase(from)) {
                isCreated = true;
                aux.addResponse(msg);
            }
        }
        if (!isCreated) {
            InstantMessageFrame aux = new InstantMessageFrame(me,
                    from, this);
            aux.setVisible(true);
            aux.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
            imList.add(aux);
            aux.addResponse(msg);
        }
    }

    /**
     * Method to create a new Instant Message Frame.
     */
    private void openInstantMessageFrame() {
        boolean isCreated = false;
        for (int i = 0; i < imList.size(); i++) {
            InstantMessageFrame aux = imList.get(i);
            if (aux.getTo().equalsIgnoreCase(friendsList.getSelectedValue()
                    .toString())) {
                isCreated = true;
                aux.setVisible(true);
            }
        }
        if (!isCreated) {
            friendsPopupMenu.setVisible(false);
            InstantMessageFrame instMsg =
                    new InstantMessageFrame(me, friendsModel.getUserAt(
                    friendsList.getSelectedIndex()), this);
            instMsg.setVisible(true);
            instMsg.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
            imList.add(instMsg);
        }
    }

    /**
     * Method to remove an InstantMessageFrame from the list.
     * @param instMess the InstantMessageFrame to remove
     */
    public void removeIm(final InstantMessageFrame instMess) {
        imList.remove(instMess);
    }

    /**
     * Method to add a friend which have connected.
     * @param name the name of the connected user
     */
    public void addFriend(final String name) {
        friendsModel.addElement(name);
    }

    /**
     * Method to remove a friend which have disconnected.
     * @param name the name of the disconnected user
     */
    public void removeFriend(final String name) {
        friendsModel.removeElement(name);
    }

    /**
     * Method to remove all the friends.
     */
    public void removeFriends() {
        friendsModel.removeAllElements();
    }

    /**
     * Method to set an information Dialog.
     * @param info the information to show
     */
    public void addInfo(final String info) {
        JOptionPane.showMessageDialog(this, info, "Information",
                JOptionPane.INFORMATION_MESSAGE);
    }

    /**
     * Method to set an error Dialog.
     * @param error the error to be shown
     */
    public void addError(final String error) {
        JOptionPane.showMessageDialog(this, error, "Error",
                JOptionPane.ERROR_MESSAGE);
    }

    /**
     * Method to set a warning.
     * @param warning the warning to show
     */
    public void addWarning(final String warning) {
        JOptionPane.showMessageDialog(this, warning, "Warning",
                JOptionPane.WARNING_MESSAGE);
    }

    /**
     * Method to show a personal message.
     * @param icon the icon to show
     * @param title the title of the window
     * @param message the message to show
     */
    public void addPersonalMessage(final ImageIcon icon, final String title,
            final String message) {
        JOptionPane.showMessageDialog(this, message, title,
                JOptionPane.INFORMATION_MESSAGE, icon);
    }

    /**
     * If there isn't a previous error about the connection, we show this
     * error.
     */
    private void errorLogin() {
        if (!connectionError) {
            addError("Your username or password is incorrect");
        }
    }

    /**
     * If we are trying to execute an action and we aren't logged.
     */
    private void errorNotLogged() {
        mainTabbedPane.setSelectedIndex(4);
        addError("You are not logged!");
    }

    /**
     * There were an error connecting, it shows the message.
     */
    public void connectionState(final boolean state) {
        if (!state) {
            addError("Error connecting to GoogleTalk. Please, make sure that you are connected to Internet");
            connectionError = true;
            return;
        }
        connectionError = false;
    }

    /**
     * If we are connected, we execute the necessary actions.
     */
    private void connected() {
        friendsNetworkAdvancedSearchCheckBox.setEnabled(true);
        isLogin = true;
        disconnectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/disconnectButton.png")));
        disconnectButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/disconnectButtonPressed.png")));
        loginGoogleAccountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/loginDisconnectButton.png")));
        loginGoogleAccountButton.setPressedIcon(new javax.swing.ImageIcon(
                getClass().getResource(
                "/graphics/loginDisconnectButtonPressed.png")));
    }

    /**
     * If we have disconnected, we execute the necessary actions.
     */
    private void disconnected() {
        friendsNetworkAdvancedSearchCheckBox.setSelected(false);
        friendsNetworkAdvancedSearchCheckBox.setEnabled(false);
        localAdvancedSearchCheckBox.setEnabled(true);
        controller.logout();
        me = "";
        isLogin = false;
        disconnectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/connectButton.png")));
        disconnectButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/connectButtonPressed.png")));
        loginGoogleAccountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/loginButton.png")));
        loginGoogleAccountButton.setPressedIcon(new javax.swing.ImageIcon(
                getClass().getResource("/graphics/loginButtonPressed.png")));
    }

    /**
     * Method to execute the necessary actions when we receive a content.
     * @param c the received content
     */
    public void contentReceived(final Content c) {
        if (c.getDescriptionContent().getProperty("properties")
                instanceof Photo) {
            if (LOG.isInfoEnabled()) {
                LOG.info("The content received is an image");
            }
            Photo p = (Photo)
                    c.getDescriptionContent().getProperty("properties");
            String newUrl = p.getURL();
            final int index = newUrl.lastIndexOf("/");
            final int index2 = newUrl.lastIndexOf(".");
            final String ext = newUrl.substring(index2 + 1);
            if (index != -1) {
                newUrl = newUrl.substring(index + 1, index2);
            }
            newUrl = grupb.upf.util.Config
                        .getProperty("photo.folder.incoming") + newUrl;
            final ImageIcon image = (ImageIcon) c.getContent();
            Image img = image.getImage();
            BufferedImage bi = new BufferedImage(img.getWidth(null),
                    img.getHeight(null), BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();
            g2.drawImage(img, 0, 0, null);
            g2.dispose();
            String aux = newUrl + "." + ext;
            File f = new File(aux);
            if (f.exists()) {
                int i = 1;
                while (f.exists()) {
                    aux = newUrl + "(" + i + ")." + ext;
                    f = new File(aux);
                }
            }
            if (LOG.isInfoEnabled()) {
                final StringBuffer sb = new StringBuffer(
                        "Trying to store it as: ")
                        .append(aux);
                LOG.info(sb);
            }
            try {
                ImageIO.write(bi, ext, f);
            } catch (IOException ex) {
                LOG.fatal("Error storing the received image", ex);
            }
            photoEdition.newPhoto(f, p);
            viewPhoto(f);
        }
    }

    /**
     * Method to resize the right menu.
     */
    private void calculateDimensioning() {
        quickSearchPanel.setVisible(quickSearchPanelVisible);
        friendsPanel.setVisible(friendsPanelVisible);
        chatPanel.setVisible(chatPanelVisible);
    }

    /**
     * Method to save the properties.
     */
    private void saveProperties() {
        if (LOG.isInfoEnabled()) {
            LOG.info("Saving properties file.");
        }
        try {
            grupb.upf.util.Config.saveProperties();
        } catch (IOException ex) {
            LOG.fatal("Error storing the configuration", ex);
        }
    }

    /**
     * Method to login or logout.
     */
    private void login() {
        if (isLogin == false) {
            if (nameGoogleAccountTextField.getText().length() != 0
                    && !new String(passwordGoogleAccountPasswordField
                    .getPassword()).trim().isEmpty()) {
                String name = nameGoogleAccountTextField.getText()
                        .toString().trim();
                if (name.indexOf("@") == -1) {
                    name += "@gmail.com";
                }
                final String password = new String(
                        passwordGoogleAccountPasswordField.getPassword())
                        .trim();
                if (controller.login(name, password, "home")) {
                    this.me = name;
                    if (rememberGoogleAccountCheckBox.isSelected()) {
                        grupb.upf.util.Config
                        .setProperty("account.google.username", name);
                        grupb.upf.util.Config
                        .setProperty("account.google.password", password);
                    } else {
                        grupb.upf.util.Config
                        .setProperty("account.google.username", "");
                        grupb.upf.util.Config
                        .setProperty("account.google.password", "");
                    }
                    saveProperties();
                    connected();
                } else {
                    LOG.info("Aqui");
                    mainTabbedPane.setSelectedIndex(4);
                    errorLogin();
                }
            } else {
                addError("User and Password can't be empty");
                mainTabbedPane.setSelectedIndex(4);
                nameGoogleAccountTextField.selectAll();
            }
        } else {
            disconnected();
        }
    }

    /**
     * Method to add a response to the TextArea.
     * @param msg the message to add.
     */
    public void chatMessageReceived(final String msg, final String from) {
        final StringBuffer sb = new StringBuffer(
                grupb.upf.util.Utilities.getName(from))
                .append(": ").append(msg).append("\n");
        outputTextArea.append(sb.toString());
        jScrollPane2.getVerticalScrollBar().setValue(
                jScrollPane2.getVerticalScrollBar().getMaximum());
    }

    /**
     * Method to send a message.
     */
    public void sendMessage() {
        if (isLogin) {
            final String msg = inputTextField.getText();
            final StringBuffer sb = new StringBuffer(
                    grupb.upf.util.Utilities.getName(me))
                    .append(": ").append(msg).append("\n");
            outputTextArea.append(sb.toString());
            controller.sendChatMessage(msg);
            inputTextField.setText("");
            jScrollPane2.getVerticalScrollBar().setValue(
                    jScrollPane2.getVerticalScrollBar().getMaximum());
        } else {
            errorNotLogged();
        }
    }

    /**
     * Method to set up the years of the combobox From.
     */
    private void addYearsFrom() {
        final Calendar cal = Calendar.getInstance();
        final int firstYear = 2000;
        final int thisYear = cal.get(Calendar.YEAR);
        yearFromComboBox.removeAllItems();
        yearFromComboBox.addItem("yyyy");
        for (int i = thisYear; i >= firstYear; i--) {
            yearFromComboBox.addItem(i);
        }
    }

    /**
     * Method to set up the years of the combobox From.
     * @param selectedYear the selected year
     */
    private void addYearsTo(final int selectedYear) {
        final Calendar cal = Calendar.getInstance();
        final int thisYear = cal.get(Calendar.YEAR);
        yearToComboBox.removeAllItems();
        for (int i = thisYear; i >= selectedYear; i--) {
            yearToComboBox.addItem(i);
        }
        yearToComboBox.setEnabled(true);
    }

    /**
     * Method to enable and add the months.
     * @param selectedYear the selected year
     */
    private void addMonthsFrom(final int selectedYear) {
        int months = 12;
        final Calendar cal = Calendar.getInstance();
        final int thisYear = cal.get(Calendar.YEAR);
        if (selectedYear == thisYear) {
            months = cal.get(Calendar.MONTH) + 1;
        }
        monthFromComboBox.removeAllItems();
        monthFromComboBox.addItem("mm");
        for (int i = 1; i <= months; i++) {
            monthFromComboBox.addItem(i);
        }
        monthFromComboBox.setEnabled(true);
    }

    /**
     * Method to enable and add the months.
     * @param selectedYearTo the selected year in yearToComboBox
     * @param selectedYearFrom the selected year in yearFromComboBox
     * @param selectedMonthFrom the selected month in monthFromComboBox
     */
    private void addMonthsTo(final int selectedYearTo,
            final int selectedYearFrom, final int selectedMonthFrom) {
        int maxMonths = 12;
        int minMonths = 1;
        final Calendar cal = Calendar.getInstance();
        final int thisYear = cal.get(Calendar.YEAR);
        final int thisMonth = cal.get(Calendar.MONTH) + 1;
        if (selectedYearTo == thisYear) {
            maxMonths = thisMonth;
        }
        if (selectedYearFrom == selectedYearTo) {
            minMonths = selectedMonthFrom;
        }
        monthToComboBox.removeAllItems();
        for (int i = minMonths; i <= maxMonths; i++) {
            monthToComboBox.addItem(i);
        }
        monthToComboBox.setEnabled(true);
    }

    /**
     * Method to enable and add the days of a month.
     * @param selectedYear the selected year
     * @param selectedMonth the month selected
     */
    private void addDaysFrom(final int selectedYear, final int selectedMonth) {
        int days = 0;
        final Calendar cal = Calendar.getInstance();
        final int thisYear = cal.get(Calendar.YEAR);
        final int thisMonth = cal.get(Calendar.MONTH) + 1;
        final int today = cal.get(Calendar.DATE);

        if (thisYear == selectedYear && thisMonth == selectedMonth) {
            days = today;
        } else if (selectedMonth == 2) {
            if ((selectedYear % 4) == 0 && ((selectedYear / 100) != 0 || (selectedYear / 400) == 0)) {
                days = 29;
            } else {
                days = 28;
            }
        } else if (selectedMonth <= 7 && (selectedMonth % 2) != 0) {
            days = 31;
        } else {
            days = 30;
        }
        dayFromComboBox.removeAllItems();
        dayFromComboBox.addItem("dd");
        for (int i = 1; i <= days; i++) {
            dayFromComboBox.addItem(i);
        }
        dayFromComboBox.setEnabled(true);
    }

    /**
     * Method to add the days to the daysToComboBox.
     * @param selectedYearTo selected year in the to combo
     * @param selectedYearFrom selected year in the from combo
     * @param selectedMonthTo selected month in the to combo
     * @param selectedMonthFrom selected month in the from combo
     * @param selectedDayFrom selected day in the from combo
     */
    private void addDaysTo(final int selectedYearTo, final int selectedYearFrom,
            final int selectedMonthTo, final int selectedMonthFrom,
            final int selectedDayFrom) {
        int days = 0;
        int minDays = 1;
        final Calendar cal = Calendar.getInstance();
        final int thisYear = cal.get(Calendar.YEAR);
        final int thisMonth = cal.get(Calendar.MONTH) + 1;
        final int today = cal.get(Calendar.DATE);
        if (selectedYearTo == selectedYearFrom && selectedMonthTo == selectedMonthFrom) {
            minDays = selectedDayFrom;
        }
        if (thisYear == selectedYearTo && thisMonth == selectedMonthTo) {
            days = today;
        } else if (selectedMonthTo == 2) {
            if ((selectedYearTo % 4) == 0 && ((selectedYearTo / 100) != 0 || (selectedYearTo / 400) == 0)) {
                days = 29;
            } else {
                days = 28;
            }
        } else if (selectedMonthTo <= 7 && (selectedMonthTo % 2) != 0) {
            days = 31;
        } else {
            days = 30;
        }
        dayToComboBox.removeAllItems();
        for (int i = minDays; i <= days; i++) {
            dayToComboBox.addItem(i);
        }
        dayToComboBox.setEnabled(true);
    }

    /**
     * Method to view a Photo.
     * @param f the photo
     */
    public void viewPhoto(final File f) {
        ((ListExplorer) listExplorerList.get(0)).setVisible(false);
        photoEdition.setPhoto(f);
        photoEdition.setVisible(true);
        mainTabbedPane.setSelectedIndex(0);
        this.repaint();
    }

    /**
     * Method to view a video.
     * @param f the video
     */
    public void viewVideo(final File f) {
        ((ListExplorer) listExplorerList.get(1)).setVisible(false);
        videoEdition.setVideo(f);
        videoEdition.setVisible(true);
        mainTabbedPane.setSelectedIndex(1);
        this.repaint();
    }

    /**
     * Method to view a new.
     * @param nw the new
     */
    public void viewNew(final New nw) {
        newViewer.setNew(nw);
        newViewer.setVisible(true);
        newEdition.setVisible(false);
        newsListPanel.setVisible(false);
        mainTabbedPane.setSelectedIndex(2);
        this.repaint();
    }
    /**
     * Method to view the list of news.
     */
    public void viewListNews() {
        newViewer.setVisible(false);
        newEdition.setVisible(false);
        initNews();
        newsListPanel.setVisible(true);
        mainTabbedPane.setSelectedIndex(2);
        this.repaint();
    }
    /**
     * Method to edit a new.
     */
    public void viewNewsEdition(final New nw) {
        newViewer.setVisible(false);
        newEdition.setNew(nw);
        newEdition.setVisible(true);
        newsListPanel.setVisible(false);
        mainTabbedPane.setSelectedIndex(2);
        this.repaint();
    }

    /**
     * Method to delete a new.
     */
    public void deleteNew() {
        if (newsTable.getSelectedRow() != -1) {
            final int index = newsTable
                            .convertRowIndexToModel(
                            newsTable.getSelectedRow());
            if (controller.deleteNew(newsTableModel.getNew(index).getID())) {
                addInfo("New deleted correctly.");
            } else {
                addError("Error deleting the new.");
            }
        }
    }
    /**
     * Method to show a list explorer.
     * @param index the index of the explorer.
     */
    public void showListExplorer(final int index) {
        switch (index) {
            case 0:
                photoEdition.setVisible(false);
                break;
            case 1:
                break;
        }
        ((ListExplorer) listExplorerList.get(index)).setVisible(true);
        this.repaint();
    }

    /**
     * Method to know if we are painting a region tag or not.
     * @return
     */
    public boolean isPaintEnabled() {
        return photoEdition.isPaintEnabled();
    }

    /**
     * Method to set up the coordenates of a region tag.
     * @param points the points of the tag
     */
    public void setCoordenates(final int[] points) {
        photoEdition.setCoordenates(points);
    }
    /**
     * Method to add a photo to the DB.
     * @param p the photo to be added
     */
    public boolean addPhoto(final Photo p) {
        return controller.addPhoto(p);
    }
    /**
     * Method to update a photo to the DB.
     * @param p the photo to be updated
     */
    public boolean updatePhoto(final Photo p) {
        return controller.updatePhoto(p);
    }
    /**
     * Method to delete a photo from the DB.
     * @param id the id of the photo to be deleted
     */
    public boolean deletePhoto(final int id) {
        return controller.deletePhoto(id);
    }
    /**
     * Method to get a photo from the DB.
     * @param url the url of the photo
     * @return the photo
     */
    public Photo getPhoto(final String url) {
        return controller.getPhoto(url);
    }
    /**
     * Method to add a video to the DB.
     * @param v the video to be added
     */
    public boolean addVideo(final Video v) {
        return controller.addVideo(v);
    }
    /**
     * Method to update a video to the DB.
     * @param v the video to be updated
     */
    public boolean updateVideo(final Video v) {
        return controller.updateVideo(v);
    }
    /**
     * Method to delete a video from the DB.
     * @param id the id of the video to be deleted
     */
    public boolean deleteVideo(final int id) {
        return controller.deleteVideo(id);
    }
    /**
     * Method to get a video from the DB.
     * @param url the url of the video
     * @return the photo
     */
    public Video getVideo(final String url) {
        return controller.getVideo(url);
    }
    /**
     * Method to add a new to the DB.
     * @param nw the new to be added
     */
    public boolean addNew(final New nw) {
        return controller.addNew(nw);
    }
    /**
     * Method to update a new to the DB.
     * @param nw the new to be updated
     */
    public boolean updateNew(final New nw) {
        return controller.updateNew(nw);
    }
    /**
     * Method to delete a new.
     * @param id the id of the new to delete
     * @return true or false
     */
    public boolean deleteNew(final int id) {
        return controller.deleteNew(id);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        friendsPopupMenu = new javax.swing.JPopupMenu();
        sendMessageMenuItem = new javax.swing.JMenuItem();
        viewPhotosMenuItem = new javax.swing.JMenuItem();
        viewVideosMenuItem = new javax.swing.JMenuItem();
        viewNewsMenuItem = new javax.swing.JMenuItem();
        ontologiesPopupMenu = new javax.swing.JPopupMenu();
        deleteDialog = new javax.swing.JDialog();
        jLabel4 = new javax.swing.JLabel();
        deleteNoButton = new javax.swing.JButton();
        deleteYesButton = new javax.swing.JButton();
        BackgroundPanel = new javax.swing.JPanel();
        disconnectButton = new javax.swing.JButton();
        mainTabbedPane = new javax.swing.JTabbedPane();
        photoPanel = new javax.swing.JPanel();
        photosDirectoriesTabbedPane = new javax.swing.JTabbedPane();
        photosPanel = new javax.swing.JPanel();
        videoPanel = new javax.swing.JPanel();
        videoTreePanel = new javax.swing.JPanel();
        videosPanel = new javax.swing.JPanel();
        newsPanel = new javax.swing.JPanel();
        newsManagerPanel = new javax.swing.JPanel();
        newsListPanel = new javax.swing.JPanel();
        optionsPanel = new javax.swing.JPanel();
        addNewButton = new javax.swing.JButton();
        editNewButton = new javax.swing.JButton();
        deleteNewButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        newsTable = new javax.swing.JTable();
        advancedSearchPanel = new javax.swing.JPanel();
        searchPanel = new javax.swing.JPanel();
        advancedSearchTextField = new javax.swing.JTextField();
        advancedSearchButton = new javax.swing.JButton();
        downloadButton = new javax.swing.JButton();
        advancedSearchOptionsPanel = new javax.swing.JPanel();
        searchNetwork = new javax.swing.JLabel();
        photoAdvancedSearchCheckBox = new javax.swing.JCheckBox();
        videoAdvancedSearchCheckBox = new javax.swing.JCheckBox();
        newsAdvancedSearchCheckBox = new javax.swing.JCheckBox();
        localAdvancedSearchCheckBox = new javax.swing.JCheckBox();
        friendsNetworkAdvancedSearchCheckBox = new javax.swing.JCheckBox();
        searchNetwork1 = new javax.swing.JLabel();
        typeOfSearchPanel = new javax.swing.JTabbedPane();
        freeSearchPanel = new javax.swing.JPanel();
        datePanel = new javax.swing.JPanel();
        yearFromComboBox = new javax.swing.JComboBox();
        monthFromComboBox = new javax.swing.JComboBox();
        dayFromComboBox = new javax.swing.JComboBox();
        yearToComboBox = new javax.swing.JComboBox();
        monthToComboBox = new javax.swing.JComboBox();
        dayToComboBox = new javax.swing.JComboBox();
        dateFromLabel = new javax.swing.JLabel();
        dateToLabel = new javax.swing.JLabel();
        searchByPanel = new javax.swing.JPanel();
        searchByLabel = new javax.swing.JLabel();
        searchByComboBox = new javax.swing.JComboBox();
        newFiltersLabel = new javax.swing.JLabel();
        advancedPhotoSearchComboBox = new javax.swing.JComboBox();
        intelligentSearchPanel = new javax.swing.JPanel();
        categoriesLabel = new javax.swing.JLabel();
        categoriesComboBox = new javax.swing.JComboBox();
        noteLabel = new javax.swing.JLabel();
        resultsHeadPanel = new javax.swing.JPanel();
        resultsScrollPane = new javax.swing.JScrollPane();
        searchResultsTable = new javax.swing.JTable();
        imageLabel = new javax.swing.JLabel();
        configurationPanel = new javax.swing.JPanel();
        googleAccountPanel = new javax.swing.JPanel();
        picasaLabel2 = new javax.swing.JLabel();
        nameGoogleAccountLabel = new javax.swing.JLabel();
        passwordGoogleAccountLabel = new javax.swing.JLabel();
        rememberGoogleAccountCheckBox = new javax.swing.JCheckBox();
        passwordGoogleAccountPasswordField = new javax.swing.JPasswordField();
        nameGoogleAccountTextField = new javax.swing.JTextField();
        loginGoogleAccountButton = new javax.swing.JButton();
        videoSettingsPanel = new javax.swing.JPanel();
        videSettingsLabel = new javax.swing.JLabel();
        vlcFolderTextField = new javax.swing.JTextField();
        vlcFolderBrowseButton = new javax.swing.JButton();
        ipTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        otherFeaturesPanel = new javax.swing.JPanel();
        saveChangesConfigurationButton = new javax.swing.JButton();
        videoFolderBrowseButton = new javax.swing.JButton();
        videoFolderTextField = new javax.swing.JTextField();
        applicationFolderLabel = new javax.swing.JLabel();
        googleAccountLabel = new javax.swing.JLabel();
        photoFolderLabel = new javax.swing.JLabel();
        photoFolderTextField = new javax.swing.JTextField();
        photoFolderBrowseButton = new javax.swing.JButton();
        photoFolderLabel1 = new javax.swing.JLabel();
        applicationFolderLabel1 = new javax.swing.JLabel();
        photoFolderTextField1 = new javax.swing.JTextField();
        videoFolderTextField1 = new javax.swing.JTextField();
        photoFolderBrowseButton1 = new javax.swing.JButton();
        videoFolderBrowseButton1 = new javax.swing.JButton();
        incomingFoldersLabel = new javax.swing.JLabel();
        generalFoldersLabel = new javax.swing.JLabel();
        rightPanel = new javax.swing.JPanel();
        quickSearchBarPanel = new javax.swing.JPanel();
        quickSearchBarLabel = new javax.swing.JLabel();
        minimizeQuickSearchPanelButton = new javax.swing.JButton();
        quickSearchPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        quickSearchTypeLabel = new javax.swing.JLabel();
        quickSearchTypeComboBox = new javax.swing.JComboBox();
        quickSearchNetworkLabel = new javax.swing.JLabel();
        quickSearchNetworkComboBox = new javax.swing.JComboBox();
        quickSearchTextField = new javax.swing.JTextField();
        quickSearchButton = new javax.swing.JButton();
        friendsBarPanel = new javax.swing.JPanel();
        friendsBarLabel = new javax.swing.JLabel();
        minimizeFriendsButton = new javax.swing.JButton();
        friendsPanel = new javax.swing.JPanel();
        friendsScrollPane = new javax.swing.JScrollPane();
        friendsList = new javax.swing.JList();
        chatBarPanel = new javax.swing.JPanel();
        chatBarLabel = new javax.swing.JLabel();
        minimizeChatButton = new javax.swing.JButton();
        chatPanel = new javax.swing.JPanel();
        chatPanelToAdjust = new javax.swing.JPanel();
        sendButton = new javax.swing.JButton();
        inputTextField = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        outputTextArea = new javax.swing.JTextArea();

        sendMessageMenuItem.setText("Send Message");
        sendMessageMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendMessageMenuItemActionPerformed(evt);
            }
        });
        friendsPopupMenu.add(sendMessageMenuItem);

        viewPhotosMenuItem.setText("View photos");
        viewPhotosMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewPhotosMenuItemActionPerformed(evt);
            }
        });
        friendsPopupMenu.add(viewPhotosMenuItem);

        viewVideosMenuItem.setText("View videos");
        viewVideosMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewVideosMenuItemActionPerformed(evt);
            }
        });
        friendsPopupMenu.add(viewVideosMenuItem);

        viewNewsMenuItem.setText("View News");
        viewNewsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewNewsMenuItemActionPerformed(evt);
            }
        });
        friendsPopupMenu.add(viewNewsMenuItem);

        ontologiesPopupMenu.setAutoscrolls(true);
        ontologiesPopupMenu.setMaximumSize(new java.awt.Dimension(260, 100));

        deleteDialog.setTitle("Delete a new");
        deleteDialog.setMinimumSize(new java.awt.Dimension(176, 100));
        deleteDialog.setResizable(false);

        jLabel4.setText("Are you sure to delete this new?");

        deleteNoButton.setText("No");
        deleteNoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteNoButtonActionPerformed(evt);
            }
        });

        deleteYesButton.setText("Yes");
        deleteYesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteYesButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout deleteDialogLayout = new javax.swing.GroupLayout(deleteDialog.getContentPane());
        deleteDialog.getContentPane().setLayout(deleteDialogLayout);
        deleteDialogLayout.setHorizontalGroup(
            deleteDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(deleteDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(deleteDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addGroup(deleteDialogLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(deleteYesButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteNoButton)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        deleteDialogLayout.setVerticalGroup(
            deleteDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(deleteDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(deleteDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(deleteYesButton)
                    .addComponent(deleteNoButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("P2Piki");
        setBackground(new java.awt.Color(102, 127, 148));
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setIconImage((new javax.swing.ImageIcon(getClass().getResource("/graphics/p2pikiLogo.png"))).getImage());
        setMinimumSize(new java.awt.Dimension(980, 600));
        setName("p2piki"); // NOI18N
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        BackgroundPanel.setBackground(new java.awt.Color(102, 102, 102));
        BackgroundPanel.setMaximumSize(new java.awt.Dimension(1005, 650));
        BackgroundPanel.setMinimumSize(new java.awt.Dimension(1005, 650));

        disconnectButton.setBackground(new java.awt.Color(102, 102, 102));
        disconnectButton.setForeground(new java.awt.Color(102, 102, 102));
        disconnectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/connectButton.png"))); // NOI18N
        disconnectButton.setBorder(null);
        disconnectButton.setFocusPainted(false);
        disconnectButton.setMaximumSize(new java.awt.Dimension(150, 48));
        disconnectButton.setMinimumSize(new java.awt.Dimension(150, 48));
        disconnectButton.setPreferredSize(new java.awt.Dimension(150, 48));
        disconnectButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/connectButtonPressed.png"))); // NOI18N
        disconnectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                disconnectButtonActionPerformed(evt);
            }
        });

        mainTabbedPane.setBackground(new java.awt.Color(153, 153, 153));
        mainTabbedPane.setFocusable(false);
        mainTabbedPane.setMaximumSize(new java.awt.Dimension(759, 628));
        mainTabbedPane.setMinimumSize(new java.awt.Dimension(759, 628));

        photoPanel.setBackground(new java.awt.Color(255, 255, 255));

        photosDirectoriesTabbedPane.setBackground(new java.awt.Color(255, 255, 255));
        photosDirectoriesTabbedPane.setMaximumSize(new java.awt.Dimension(162, 544));
        photosDirectoriesTabbedPane.setPreferredSize(new java.awt.Dimension(162, 544));

        photosPanel.setBackground(new java.awt.Color(255, 255, 255));
        photosPanel.setMaximumSize(new java.awt.Dimension(542, 556));
        photosPanel.setPreferredSize(new java.awt.Dimension(542, 556));
        photosPanel.setLayout(new javax.swing.BoxLayout(photosPanel, javax.swing.BoxLayout.LINE_AXIS));

        javax.swing.GroupLayout photoPanelLayout = new javax.swing.GroupLayout(photoPanel);
        photoPanel.setLayout(photoPanelLayout);
        photoPanelLayout.setHorizontalGroup(
            photoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(photoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(photosDirectoriesTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(photosPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE))
        );
        photoPanelLayout.setVerticalGroup(
            photoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, photoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(photoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(photosDirectoriesTabbedPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 556, Short.MAX_VALUE)
                    .addComponent(photosPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        mainTabbedPane.addTab("", new javax.swing.ImageIcon(getClass().getResource("/graphics/photoTab.png")), photoPanel); // NOI18N

        videoPanel.setBackground(new java.awt.Color(255, 255, 255));

        videoTreePanel.setBackground(new java.awt.Color(255, 255, 255));
        videoTreePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
        videoTreePanel.setMaximumSize(new java.awt.Dimension(2, 600));
        videoTreePanel.setPreferredSize(new java.awt.Dimension(162, 534));
        videoTreePanel.setLayout(new javax.swing.BoxLayout(videoTreePanel, javax.swing.BoxLayout.LINE_AXIS));

        videosPanel.setBackground(new java.awt.Color(255, 255, 255));
        videosPanel.setMaximumSize(new java.awt.Dimension(542, 546));
        videosPanel.setPreferredSize(new java.awt.Dimension(542, 546));
        videosPanel.setLayout(new javax.swing.BoxLayout(videosPanel, javax.swing.BoxLayout.LINE_AXIS));

        javax.swing.GroupLayout videoPanelLayout = new javax.swing.GroupLayout(videoPanel);
        videoPanel.setLayout(videoPanelLayout);
        videoPanelLayout.setHorizontalGroup(
            videoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, videoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(videoTreePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(videosPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(130, 130, 130))
        );
        videoPanelLayout.setVerticalGroup(
            videoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(videoPanelLayout.createSequentialGroup()
                .addGroup(videoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(videoPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(videosPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 556, Short.MAX_VALUE))
                    .addGroup(videoPanelLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(videoTreePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE)))
                .addContainerGap())
        );

        mainTabbedPane.addTab("", new javax.swing.ImageIcon(getClass().getResource("/graphics/videoTab.png")), videoPanel); // NOI18N

        newsPanel.setBackground(new java.awt.Color(255, 255, 255));

        newsManagerPanel.setBackground(new java.awt.Color(255, 255, 255));
        newsManagerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "News", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N
        newsManagerPanel.setLayout(new javax.swing.BoxLayout(newsManagerPanel, javax.swing.BoxLayout.LINE_AXIS));

        newsListPanel.setBackground(new java.awt.Color(255, 255, 255));

        optionsPanel.setBackground(new java.awt.Color(255, 255, 255));
        optionsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Options", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        addNewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/addNew.png"))); // NOI18N
        addNewButton.setText("Add new   ");
        addNewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addNewButtonActionPerformed(evt);
            }
        });

        editNewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/editNew.png"))); // NOI18N
        editNewButton.setText("Edit new    ");
        editNewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editNewButtonActionPerformed(evt);
            }
        });

        deleteNewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/deleteNew.png"))); // NOI18N
        deleteNewButton.setText("Delete new");
        deleteNewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteNewButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout optionsPanelLayout = new javax.swing.GroupLayout(optionsPanel);
        optionsPanel.setLayout(optionsPanelLayout);
        optionsPanelLayout.setHorizontalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(addNewButton, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                    .addComponent(editNewButton, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                    .addComponent(deleteNewButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        optionsPanelLayout.setVerticalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(addNewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(editNewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deleteNewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41))
        );

        newsTable.setAutoCreateRowSorter(true);
        newsTable.setModel(newsTableModel);
        newsTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(newsTable);

        javax.swing.GroupLayout newsListPanelLayout = new javax.swing.GroupLayout(newsListPanel);
        newsListPanel.setLayout(newsListPanelLayout);
        newsListPanelLayout.setHorizontalGroup(
            newsListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newsListPanelLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        newsListPanelLayout.setVerticalGroup(
            newsListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newsListPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(newsListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 471, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        newsManagerPanel.add(newsListPanel);

        javax.swing.GroupLayout newsPanelLayout = new javax.swing.GroupLayout(newsPanel);
        newsPanel.setLayout(newsPanelLayout);
        newsPanelLayout.setHorizontalGroup(
            newsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newsPanelLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(newsManagerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 697, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );
        newsPanelLayout.setVerticalGroup(
            newsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newsPanelLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(newsManagerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 535, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        mainTabbedPane.addTab("", new javax.swing.ImageIcon(getClass().getResource("/graphics/newsTab.png")), newsPanel); // NOI18N

        advancedSearchPanel.setBackground(new java.awt.Color(255, 255, 255));

        searchPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));

        advancedSearchTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                advancedSearchTextFieldKeyReleased(evt);
            }
        });

        advancedSearchButton.setBackground(new java.awt.Color(255, 255, 255));
        advancedSearchButton.setFont(new java.awt.Font("Tahoma", 1, 11));
        advancedSearchButton.setText("Search");
        advancedSearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                advancedSearchButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout searchPanelLayout = new javax.swing.GroupLayout(searchPanel);
        searchPanel.setLayout(searchPanelLayout);
        searchPanelLayout.setHorizontalGroup(
            searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(advancedSearchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(advancedSearchButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        searchPanelLayout.setVerticalGroup(
            searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, searchPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(advancedSearchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(advancedSearchButton))
                .addContainerGap())
        );

        downloadButton.setBackground(new java.awt.Color(255, 255, 255));
        downloadButton.setText("Download");
        downloadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                downloadButtonActionPerformed(evt);
            }
        });

        advancedSearchOptionsPanel.setBackground(new java.awt.Color(255, 255, 255));
        advancedSearchOptionsPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
        advancedSearchOptionsPanel.setMaximumSize(new java.awt.Dimension(842, 111));
        advancedSearchOptionsPanel.setMinimumSize(new java.awt.Dimension(842, 111));
        advancedSearchOptionsPanel.setPreferredSize(new java.awt.Dimension(842, 111));

        searchNetwork.setFont(new java.awt.Font("Tahoma", 1, 12));
        searchNetwork.setText("Type");

        photoAdvancedSearchCheckBox.setBackground(new java.awt.Color(255, 255, 255));
        photoAdvancedSearchCheckBox.setSelected(true);
        photoAdvancedSearchCheckBox.setText("Photo");
        photoAdvancedSearchCheckBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                photoAdvancedSearchCheckBoxItemStateChanged(evt);
            }
        });

        videoAdvancedSearchCheckBox.setBackground(new java.awt.Color(255, 255, 255));
        videoAdvancedSearchCheckBox.setText("Video");

        newsAdvancedSearchCheckBox.setBackground(new java.awt.Color(255, 255, 255));
        newsAdvancedSearchCheckBox.setText("News");

        localAdvancedSearchCheckBox.setBackground(new java.awt.Color(255, 255, 255));
        localAdvancedSearchCheckBox.setSelected(true);
        localAdvancedSearchCheckBox.setText("Local");

        friendsNetworkAdvancedSearchCheckBox.setBackground(new java.awt.Color(255, 255, 255));
        friendsNetworkAdvancedSearchCheckBox.setText("Friends Network");

        searchNetwork1.setFont(new java.awt.Font("Tahoma", 1, 12));
        searchNetwork1.setText("Network");

        typeOfSearchPanel.setBackground(new java.awt.Color(255, 255, 255));
        typeOfSearchPanel.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        typeOfSearchPanel.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                typeOfSearchPanelStateChanged(evt);
            }
        });

        freeSearchPanel.setBackground(new java.awt.Color(255, 255, 255));

        datePanel.setBackground(new java.awt.Color(255, 255, 255));
        datePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Date"));
        datePanel.setMaximumSize(new java.awt.Dimension(203, 78));
        datePanel.setMinimumSize(new java.awt.Dimension(203, 78));

        yearFromComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "yyyy" }));
        yearFromComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                yearFromComboBoxItemStateChanged(evt);
            }
        });

        monthFromComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "mm" }));
        monthFromComboBox.setEnabled(false);
        monthFromComboBox.setMaximumSize(new java.awt.Dimension(41, 20));
        monthFromComboBox.setMinimumSize(new java.awt.Dimension(41, 20));
        monthFromComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                monthFromComboBoxItemStateChanged(evt);
            }
        });

        dayFromComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "dd" }));
        dayFromComboBox.setEnabled(false);
        dayFromComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                dayFromComboBoxItemStateChanged(evt);
            }
        });

        yearToComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "yyyy" }));
        yearToComboBox.setEnabled(false);
        yearToComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                yearToComboBoxItemStateChanged(evt);
            }
        });

        monthToComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "mm" }));
        monthToComboBox.setEnabled(false);
        monthToComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                monthToComboBoxItemStateChanged(evt);
            }
        });

        dayToComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "dd" }));
        dayToComboBox.setEnabled(false);

        dateFromLabel.setFont(new java.awt.Font("Tahoma", 2, 11));
        dateFromLabel.setText("From");

        dateToLabel.setFont(new java.awt.Font("Tahoma", 2, 11));
        dateToLabel.setText("To");

        javax.swing.GroupLayout datePanelLayout = new javax.swing.GroupLayout(datePanel);
        datePanel.setLayout(datePanelLayout);
        datePanelLayout.setHorizontalGroup(
            datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(datePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dateFromLabel, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(dateToLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(yearToComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(yearFromComboBox, 0, 58, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(monthToComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(monthFromComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(dayToComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(dayFromComboBox, 0, 40, Short.MAX_VALUE))
                .addContainerGap())
        );
        datePanelLayout.setVerticalGroup(
            datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(datePanelLayout.createSequentialGroup()
                .addGroup(datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(monthFromComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dayFromComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dateFromLabel)
                    .addComponent(yearFromComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(datePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(yearToComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(monthToComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dayToComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dateToLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        searchByPanel.setBackground(new java.awt.Color(255, 255, 255));

        searchByLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        searchByLabel.setText("Search By");

        searchByComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Title", "Description", "Publisher", "Tags", "Date", "In a new" }));
        searchByComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                searchByComboBoxItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout searchByPanelLayout = new javax.swing.GroupLayout(searchByPanel);
        searchByPanel.setLayout(searchByPanelLayout);
        searchByPanelLayout.setHorizontalGroup(
            searchByPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchByPanelLayout.createSequentialGroup()
                .addGroup(searchByPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(searchByComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchByLabel))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        searchByPanelLayout.setVerticalGroup(
            searchByPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchByPanelLayout.createSequentialGroup()
                .addComponent(searchByLabel)
                .addGap(2, 2, 2)
                .addComponent(searchByComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        newFiltersLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        newFiltersLabel.setText("Photo Search in News");

        advancedPhotoSearchComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Title", "Subtitle", "Any paragraph", "Previous paragraph", "Following paragraph" }));

        javax.swing.GroupLayout freeSearchPanelLayout = new javax.swing.GroupLayout(freeSearchPanel);
        freeSearchPanel.setLayout(freeSearchPanelLayout);
        freeSearchPanelLayout.setHorizontalGroup(
            freeSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(freeSearchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(freeSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(advancedPhotoSearchComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(newFiltersLabel)
                    .addComponent(searchByPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addComponent(datePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(32, 32, 32))
        );
        freeSearchPanelLayout.setVerticalGroup(
            freeSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(freeSearchPanelLayout.createSequentialGroup()
                .addGroup(freeSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(freeSearchPanelLayout.createSequentialGroup()
                        .addComponent(searchByPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(newFiltersLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(advancedPhotoSearchComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(datePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        typeOfSearchPanel.addTab("Free Search", freeSearchPanel);

        intelligentSearchPanel.setBackground(new java.awt.Color(255, 255, 255));

        categoriesLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        categoriesLabel.setText("Category");

        categoriesComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------- Choose a category -------", "Category ejemplo 1", "Category ejemplo 2" }));
        categoriesComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                categoriesComboBoxItemStateChanged(evt);
            }
        });

        noteLabel.setText("First of all, you have to select a category");

        javax.swing.GroupLayout intelligentSearchPanelLayout = new javax.swing.GroupLayout(intelligentSearchPanel);
        intelligentSearchPanel.setLayout(intelligentSearchPanelLayout);
        intelligentSearchPanelLayout.setHorizontalGroup(
            intelligentSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(intelligentSearchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(intelligentSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(intelligentSearchPanelLayout.createSequentialGroup()
                        .addComponent(categoriesLabel)
                        .addGap(28, 28, 28)
                        .addComponent(categoriesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(noteLabel))
                .addContainerGap(137, Short.MAX_VALUE))
        );
        intelligentSearchPanelLayout.setVerticalGroup(
            intelligentSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, intelligentSearchPanelLayout.createSequentialGroup()
                .addContainerGap(13, Short.MAX_VALUE)
                .addComponent(noteLabel)
                .addGap(18, 18, 18)
                .addGroup(intelligentSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(categoriesLabel)
                    .addComponent(categoriesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26))
        );

        typeOfSearchPanel.addTab("Intelligent Search", intelligentSearchPanel);

        javax.swing.GroupLayout advancedSearchOptionsPanelLayout = new javax.swing.GroupLayout(advancedSearchOptionsPanel);
        advancedSearchOptionsPanel.setLayout(advancedSearchOptionsPanelLayout);
        advancedSearchOptionsPanelLayout.setHorizontalGroup(
            advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedSearchOptionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(advancedSearchOptionsPanelLayout.createSequentialGroup()
                        .addGroup(advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(videoAdvancedSearchCheckBox)
                            .addComponent(photoAdvancedSearchCheckBox))
                        .addGap(26, 26, 26)
                        .addGroup(advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(searchNetwork1)
                            .addComponent(friendsNetworkAdvancedSearchCheckBox)
                            .addComponent(localAdvancedSearchCheckBox)))
                    .addComponent(searchNetwork)
                    .addComponent(newsAdvancedSearchCheckBox))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(typeOfSearchPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 510, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        advancedSearchOptionsPanelLayout.setVerticalGroup(
            advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedSearchOptionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(advancedSearchOptionsPanelLayout.createSequentialGroup()
                        .addGroup(advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(searchNetwork)
                            .addComponent(searchNetwork1))
                        .addGap(5, 5, 5)
                        .addGroup(advancedSearchOptionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(advancedSearchOptionsPanelLayout.createSequentialGroup()
                                .addComponent(friendsNetworkAdvancedSearchCheckBox)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(localAdvancedSearchCheckBox))
                            .addGroup(advancedSearchOptionsPanelLayout.createSequentialGroup()
                                .addComponent(photoAdvancedSearchCheckBox)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(videoAdvancedSearchCheckBox)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(newsAdvancedSearchCheckBox))
                    .addComponent(typeOfSearchPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        resultsHeadPanel.setBackground(new java.awt.Color(255, 255, 255));
        resultsHeadPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Results", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        resultsScrollPane.setBackground(new java.awt.Color(255, 255, 255));
        resultsScrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        searchResultsTable.setAutoCreateRowSorter(true);
        searchResultsTable.setModel(searchTableModel);
        searchResultsTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
        searchResultsTable.setGridColor(new java.awt.Color(255, 255, 255));
        resultsScrollPane.setViewportView(searchResultsTable);

        imageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        imageLabel.setAutoscrolls(true);
        imageLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        javax.swing.GroupLayout resultsHeadPanelLayout = new javax.swing.GroupLayout(resultsHeadPanel);
        resultsHeadPanel.setLayout(resultsHeadPanelLayout);
        resultsHeadPanelLayout.setHorizontalGroup(
            resultsHeadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, resultsHeadPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(resultsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        resultsHeadPanelLayout.setVerticalGroup(
            resultsHeadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(resultsHeadPanelLayout.createSequentialGroup()
                .addGroup(resultsHeadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(resultsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout advancedSearchPanelLayout = new javax.swing.GroupLayout(advancedSearchPanel);
        advancedSearchPanel.setLayout(advancedSearchPanelLayout);
        advancedSearchPanelLayout.setHorizontalGroup(
            advancedSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedSearchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(advancedSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(advancedSearchOptionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 720, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(advancedSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, advancedSearchPanelLayout.createSequentialGroup()
                            .addComponent(searchPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(483, 483, 483))
                        .addComponent(downloadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(resultsHeadPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        advancedSearchPanelLayout.setVerticalGroup(
            advancedSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedSearchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(searchPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(advancedSearchOptionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(resultsHeadPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(downloadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(105, 105, 105))
        );

        mainTabbedPane.addTab("", new javax.swing.ImageIcon(getClass().getResource("/graphics/advancedSearchTab.png")), advancedSearchPanel); // NOI18N

        configurationPanel.setBackground(new java.awt.Color(255, 255, 255));

        googleAccountPanel.setBackground(new java.awt.Color(255, 255, 255));
        googleAccountPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        picasaLabel2.setFont(new java.awt.Font("Verdana", 1, 14));
        picasaLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/googleAccount.png"))); // NOI18N
        picasaLabel2.setText("Google Account");

        nameGoogleAccountLabel.setFont(new java.awt.Font("Verdana", 1, 10));
        nameGoogleAccountLabel.setText("Username");

        passwordGoogleAccountLabel.setFont(new java.awt.Font("Verdana", 1, 10));
        passwordGoogleAccountLabel.setText("Password");

        rememberGoogleAccountCheckBox.setBackground(new java.awt.Color(255, 255, 255));
        rememberGoogleAccountCheckBox.setSelected(true);
        rememberGoogleAccountCheckBox.setText("Remember");
        rememberGoogleAccountCheckBox.setNextFocusableComponent(loginGoogleAccountButton);

        passwordGoogleAccountPasswordField.setText(grupb.upf.util.Config.getProperty("account.google.password"));
        passwordGoogleAccountPasswordField.setAutoscrolls(false);
        passwordGoogleAccountPasswordField.setMaximumSize(new java.awt.Dimension(6, 20));

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, rememberGoogleAccountCheckBox, org.jdesktop.beansbinding.ObjectProperty.create(), passwordGoogleAccountPasswordField, org.jdesktop.beansbinding.BeanProperty.create("nextFocusableComponent"));
        bindingGroup.addBinding(binding);

        passwordGoogleAccountPasswordField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                passwordGoogleAccountPasswordFieldFocusGained(evt);
            }
        });
        passwordGoogleAccountPasswordField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                passwordGoogleAccountPasswordFieldKeyPressed(evt);
            }
        });

        nameGoogleAccountTextField.setText(grupb.upf.util.Config.getProperty("account.google.username"));
        nameGoogleAccountTextField.setAutoscrolls(false);
        nameGoogleAccountTextField.setMaximumSize(new java.awt.Dimension(6, 20));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, passwordGoogleAccountPasswordField, org.jdesktop.beansbinding.ObjectProperty.create(), nameGoogleAccountTextField, org.jdesktop.beansbinding.BeanProperty.create("nextFocusableComponent"));
        bindingGroup.addBinding(binding);

        loginGoogleAccountButton.setBackground(new java.awt.Color(255, 255, 255));
        loginGoogleAccountButton.setFont(new java.awt.Font("Tahoma", 0, 10));
        loginGoogleAccountButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/loginButton.png"))); // NOI18N
        loginGoogleAccountButton.setBorder(null);
        loginGoogleAccountButton.setFocusPainted(false);
        loginGoogleAccountButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/loginButtonPressed.png"))); // NOI18N
        loginGoogleAccountButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginGoogleAccountButtonActionPerformed(evt);
            }
        });

        videoSettingsPanel.setBackground(new java.awt.Color(255, 255, 255));

        videSettingsLabel.setFont(new java.awt.Font("Verdana", 1, 14));
        videSettingsLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/video2.png"))); // NOI18N
        videSettingsLabel.setText("Video Settings");

        vlcFolderTextField.setText(grupb.upf.util.Config.getProperty("vlc.folder"));
        vlcFolderTextField.setAutoscrolls(false);
        vlcFolderTextField.setFocusable(false);
        vlcFolderTextField.setMaximumSize(new java.awt.Dimension(6, 20));

        vlcFolderBrowseButton.setFont(new java.awt.Font("Tahoma", 0, 10));
        vlcFolderBrowseButton.setText("Browse");
        vlcFolderBrowseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vlcFolderBrowseButtonActionPerformed(evt);
            }
        });

        ipTextField.setText(grupb.upf.util.Config.getProperty("ip"));
        ipTextField.setAutoscrolls(false);
        ipTextField.setMaximumSize(new java.awt.Dimension(190, 20));
        ipTextField.setMinimumSize(new java.awt.Dimension(190, 20));
        ipTextField.setPreferredSize(new java.awt.Dimension(190, 20));

        jLabel1.setText("VLC Folder");

        jLabel2.setText("Your Public IP");

        javax.swing.GroupLayout videoSettingsPanelLayout = new javax.swing.GroupLayout(videoSettingsPanel);
        videoSettingsPanel.setLayout(videoSettingsPanelLayout);
        videoSettingsPanelLayout.setHorizontalGroup(
            videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(videoSettingsPanelLayout.createSequentialGroup()
                .addGroup(videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(videoSettingsPanelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(videSettingsLabel))
                    .addGroup(videoSettingsPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(videoSettingsPanelLayout.createSequentialGroup()
                                .addComponent(vlcFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(vlcFolderBrowseButton))
                            .addComponent(ipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        videoSettingsPanelLayout.setVerticalGroup(
            videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(videoSettingsPanelLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(videSettingsLabel)
                .addGap(33, 33, 33)
                .addGroup(videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(vlcFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(vlcFolderBrowseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(videoSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(ipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(65, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout googleAccountPanelLayout = new javax.swing.GroupLayout(googleAccountPanel);
        googleAccountPanel.setLayout(googleAccountPanelLayout);
        googleAccountPanelLayout.setHorizontalGroup(
            googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(googleAccountPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(picasaLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rememberGoogleAccountCheckBox)
                    .addGroup(googleAccountPanelLayout.createSequentialGroup()
                        .addGroup(googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(passwordGoogleAccountLabel)
                            .addComponent(nameGoogleAccountLabel))
                        .addGap(36, 36, 36)
                        .addGroup(googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(nameGoogleAccountTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(passwordGoogleAccountPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addComponent(loginGoogleAccountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(videoSettingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        googleAccountPanelLayout.setVerticalGroup(
            googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(googleAccountPanelLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(picasaLabel2)
                .addGap(28, 28, 28)
                .addGroup(googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(googleAccountPanelLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameGoogleAccountTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(nameGoogleAccountLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(googleAccountPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(passwordGoogleAccountPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(passwordGoogleAccountLabel))
                        .addGap(9, 9, 9)
                        .addComponent(rememberGoogleAccountCheckBox))
                    .addComponent(loginGoogleAccountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(66, 66, 66)
                .addComponent(videoSettingsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        otherFeaturesPanel.setBackground(new java.awt.Color(255, 255, 255));
        otherFeaturesPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        saveChangesConfigurationButton.setFont(new java.awt.Font("Tahoma", 0, 10));
        saveChangesConfigurationButton.setText("Save Changes");
        saveChangesConfigurationButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveChangesConfigurationButtonActionPerformed(evt);
            }
        });

        videoFolderBrowseButton.setFont(new java.awt.Font("Tahoma", 0, 10));
        videoFolderBrowseButton.setText("Browse");
        videoFolderBrowseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                videoFolderBrowseButtonActionPerformed(evt);
            }
        });

        videoFolderTextField.setText(grupb.upf.util.Config.getProperty("video.folder"));
        videoFolderTextField.setAutoscrolls(false);
        videoFolderTextField.setFocusable(false);
        videoFolderTextField.setMaximumSize(new java.awt.Dimension(6, 20));

        applicationFolderLabel.setFont(new java.awt.Font("Verdana", 0, 10));
        applicationFolderLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/folder_video.png"))); // NOI18N
        applicationFolderLabel.setText("Videos folder");

        googleAccountLabel.setFont(new java.awt.Font("Verdana", 1, 16));
        googleAccountLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/generalConfiguration.png"))); // NOI18N
        googleAccountLabel.setText("General");

        photoFolderLabel.setFont(new java.awt.Font("Verdana", 0, 10));
        photoFolderLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/folder_image.png"))); // NOI18N
        photoFolderLabel.setText("Photos folder");

        photoFolderTextField.setText(grupb.upf.util.Config.getProperty("photo.folder"));
        photoFolderTextField.setAutoscrolls(false);
        photoFolderTextField.setFocusable(false);
        photoFolderTextField.setMaximumSize(new java.awt.Dimension(6, 20));

        photoFolderBrowseButton.setFont(new java.awt.Font("Tahoma", 0, 10));
        photoFolderBrowseButton.setText("Browse");
        photoFolderBrowseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                photoFolderBrowseButtonActionPerformed(evt);
            }
        });

        photoFolderLabel1.setFont(new java.awt.Font("Verdana", 0, 10));
        photoFolderLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/folder_image_incoming.png"))); // NOI18N
        photoFolderLabel1.setText("Photos folder");

        applicationFolderLabel1.setFont(new java.awt.Font("Verdana", 0, 10));
        applicationFolderLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/folder_video_incoming.png"))); // NOI18N
        applicationFolderLabel1.setText("Videos folder");

        photoFolderTextField1.setText(grupb.upf.util.Config.getProperty("photo.folder.incoming"));
        photoFolderTextField1.setAutoscrolls(false);
        photoFolderTextField1.setFocusable(false);
        photoFolderTextField1.setMaximumSize(new java.awt.Dimension(6, 20));

        videoFolderTextField1.setText(grupb.upf.util.Config.getProperty("video.folder.incoming"));
        videoFolderTextField1.setAutoscrolls(false);
        videoFolderTextField1.setFocusable(false);
        videoFolderTextField1.setMaximumSize(new java.awt.Dimension(6, 20));

        photoFolderBrowseButton1.setFont(new java.awt.Font("Tahoma", 0, 10));
        photoFolderBrowseButton1.setText("Browse");
        photoFolderBrowseButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                photoFolderBrowseButton1ActionPerformed(evt);
            }
        });

        videoFolderBrowseButton1.setFont(new java.awt.Font("Tahoma", 0, 10));
        videoFolderBrowseButton1.setText("Browse");
        videoFolderBrowseButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                videoFolderBrowseButton1ActionPerformed(evt);
            }
        });

        incomingFoldersLabel.setFont(new java.awt.Font("Verdana", 1, 12));
        incomingFoldersLabel.setText("Incoming Folders");

        generalFoldersLabel.setFont(new java.awt.Font("Verdana", 1, 12));
        generalFoldersLabel.setText("General Folders");

        javax.swing.GroupLayout otherFeaturesPanelLayout = new javax.swing.GroupLayout(otherFeaturesPanel);
        otherFeaturesPanel.setLayout(otherFeaturesPanelLayout);
        otherFeaturesPanelLayout.setHorizontalGroup(
            otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(otherFeaturesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(otherFeaturesPanelLayout.createSequentialGroup()
                        .addComponent(googleAccountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(129, 129, 129))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, otherFeaturesPanelLayout.createSequentialGroup()
                        .addComponent(saveChangesConfigurationButton, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(otherFeaturesPanelLayout.createSequentialGroup()
                        .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(otherFeaturesPanelLayout.createSequentialGroup()
                                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(applicationFolderLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                                    .addComponent(photoFolderLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, otherFeaturesPanelLayout.createSequentialGroup()
                                        .addComponent(photoFolderTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(photoFolderBrowseButton))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, otherFeaturesPanelLayout.createSequentialGroup()
                                        .addComponent(videoFolderTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(videoFolderBrowseButton))))
                            .addComponent(generalFoldersLabel))
                        .addContainerGap())
                    .addGroup(otherFeaturesPanelLayout.createSequentialGroup()
                        .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(applicationFolderLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                            .addComponent(photoFolderLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                            .addComponent(incomingFoldersLabel, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, otherFeaturesPanelLayout.createSequentialGroup()
                                .addComponent(photoFolderTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(photoFolderBrowseButton1))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, otherFeaturesPanelLayout.createSequentialGroup()
                                .addComponent(videoFolderTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(videoFolderBrowseButton1)))
                        .addContainerGap())))
        );
        otherFeaturesPanelLayout.setVerticalGroup(
            otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(otherFeaturesPanelLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(googleAccountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40)
                .addComponent(generalFoldersLabel)
                .addGap(18, 18, 18)
                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(photoFolderBrowseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(photoFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(photoFolderLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(videoFolderBrowseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(videoFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(applicationFolderLabel))
                .addGap(55, 55, 55)
                .addComponent(incomingFoldersLabel)
                .addGap(18, 18, 18)
                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(photoFolderBrowseButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(photoFolderTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(photoFolderLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(otherFeaturesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(applicationFolderLabel1)
                    .addComponent(videoFolderTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(videoFolderBrowseButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(55, 55, 55)
                .addComponent(saveChangesConfigurationButton, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );

        javax.swing.GroupLayout configurationPanelLayout = new javax.swing.GroupLayout(configurationPanel);
        configurationPanel.setLayout(configurationPanelLayout);
        configurationPanelLayout.setHorizontalGroup(
            configurationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(configurationPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(googleAccountPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(otherFeaturesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(21, 21, 21))
        );
        configurationPanelLayout.setVerticalGroup(
            configurationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(configurationPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(configurationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(otherFeaturesPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
                    .addComponent(googleAccountPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        mainTabbedPane.addTab("", new javax.swing.ImageIcon(getClass().getResource("/graphics/configTab.png")), configurationPanel); // NOI18N

        rightPanel.setBackground(new java.awt.Color(102, 102, 102));

        quickSearchBarPanel.setBackground(new java.awt.Color(51, 51, 51));
        quickSearchBarPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        quickSearchBarPanel.setAlignmentY(0.0F);
        quickSearchBarPanel.setMaximumSize(new java.awt.Dimension(220, 27));
        quickSearchBarPanel.setMinimumSize(new java.awt.Dimension(220, 27));

        quickSearchBarLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        quickSearchBarLabel.setForeground(new java.awt.Color(255, 255, 255));
        quickSearchBarLabel.setText("Quick Search");

        minimizeQuickSearchPanelButton.setBackground(new java.awt.Color(51, 51, 51));
        minimizeQuickSearchPanelButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/minimizeButton.png"))); // NOI18N
        minimizeQuickSearchPanelButton.setFocusPainted(false);
        minimizeQuickSearchPanelButton.setMaximumSize(new java.awt.Dimension(21, 22));
        minimizeQuickSearchPanelButton.setMinimumSize(new java.awt.Dimension(21, 22));
        minimizeQuickSearchPanelButton.setPreferredSize(new java.awt.Dimension(21, 22));
        minimizeQuickSearchPanelButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/minimizeButtonPressed.png"))); // NOI18N
        minimizeQuickSearchPanelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minimizeQuickSearchPanelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout quickSearchBarPanelLayout = new javax.swing.GroupLayout(quickSearchBarPanel);
        quickSearchBarPanel.setLayout(quickSearchBarPanelLayout);
        quickSearchBarPanelLayout.setHorizontalGroup(
            quickSearchBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(quickSearchBarPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(quickSearchBarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE)
                .addComponent(minimizeQuickSearchPanelButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        quickSearchBarPanelLayout.setVerticalGroup(
            quickSearchBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(quickSearchBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(minimizeQuickSearchPanelButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(quickSearchBarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        quickSearchPanel.setMaximumSize(new java.awt.Dimension(220, 67));
        quickSearchPanel.setMinimumSize(new java.awt.Dimension(220, 0));
        quickSearchPanel.setPreferredSize(new java.awt.Dimension(220, 67));

        quickSearchTypeLabel.setFont(new java.awt.Font("Tahoma", 0, 10));
        quickSearchTypeLabel.setText("Type");

        quickSearchTypeComboBox.setFont(new java.awt.Font("Tahoma", 0, 10));
        quickSearchTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Photo", "Video", "New" }));

        quickSearchNetworkLabel.setFont(new java.awt.Font("Tahoma", 0, 10));
        quickSearchNetworkLabel.setText("Network");

        quickSearchNetworkComboBox.setFont(new java.awt.Font("Tahoma", 0, 10));
        quickSearchNetworkComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Friends", "Local", "All" }));

        quickSearchButton.setFont(new java.awt.Font("Tahoma", 1, 11));
        quickSearchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/searchButton.png"))); // NOI18N
        quickSearchButton.setBorder(null);
        quickSearchButton.setFocusPainted(false);
        quickSearchButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/searchButtonPressed.png"))); // NOI18N
        quickSearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quickSearchButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(quickSearchTypeLabel)
                        .addGap(2, 2, 2)
                        .addComponent(quickSearchTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(quickSearchNetworkLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(quickSearchNetworkComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(quickSearchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(quickSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(quickSearchButton, 0, 0, Short.MAX_VALUE)
                    .addComponent(quickSearchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(quickSearchTypeLabel)
                    .addComponent(quickSearchTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(quickSearchNetworkLabel)
                    .addComponent(quickSearchNetworkComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        javax.swing.GroupLayout quickSearchPanelLayout = new javax.swing.GroupLayout(quickSearchPanel);
        quickSearchPanel.setLayout(quickSearchPanelLayout);
        quickSearchPanelLayout.setHorizontalGroup(
            quickSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(quickSearchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        quickSearchPanelLayout.setVerticalGroup(
            quickSearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(quickSearchPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        friendsBarPanel.setBackground(new java.awt.Color(51, 51, 51));
        friendsBarPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        friendsBarPanel.setMaximumSize(new java.awt.Dimension(220, 27));
        friendsBarPanel.setMinimumSize(new java.awt.Dimension(220, 27));
        friendsBarPanel.setPreferredSize(new java.awt.Dimension(220, 27));

        friendsBarLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        friendsBarLabel.setForeground(new java.awt.Color(255, 255, 255));
        friendsBarLabel.setText("Friends");

        minimizeFriendsButton.setBackground(new java.awt.Color(51, 51, 51));
        minimizeFriendsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/minimizeButton.png"))); // NOI18N
        minimizeFriendsButton.setFocusPainted(false);
        minimizeFriendsButton.setMaximumSize(new java.awt.Dimension(21, 22));
        minimizeFriendsButton.setMinimumSize(new java.awt.Dimension(21, 22));
        minimizeFriendsButton.setPreferredSize(new java.awt.Dimension(21, 22));
        minimizeFriendsButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/minimizeButtonPressed.png"))); // NOI18N
        minimizeFriendsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minimizeFriendsButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout friendsBarPanelLayout = new javax.swing.GroupLayout(friendsBarPanel);
        friendsBarPanel.setLayout(friendsBarPanelLayout);
        friendsBarPanelLayout.setHorizontalGroup(
            friendsBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, friendsBarPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(friendsBarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 117, Short.MAX_VALUE)
                .addComponent(minimizeFriendsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        friendsBarPanelLayout.setVerticalGroup(
            friendsBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(friendsBarPanelLayout.createSequentialGroup()
                .addGroup(friendsBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(friendsBarLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(minimizeFriendsButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        friendsPanel.setMaximumSize(new java.awt.Dimension(220, 215));
        friendsPanel.setMinimumSize(new java.awt.Dimension(220, 0));
        friendsPanel.setPreferredSize(new java.awt.Dimension(220, 185));

        friendsScrollPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(240, 240, 240)));

        friendsList.setBackground(new java.awt.Color(240, 240, 240));
        friendsList.setModel(friendsModel);
        friendsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        friendsList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                friendsListMouseClicked(evt);
            }
        });
        friendsScrollPane.setViewportView(friendsList);

        javax.swing.GroupLayout friendsPanelLayout = new javax.swing.GroupLayout(friendsPanel);
        friendsPanel.setLayout(friendsPanelLayout);
        friendsPanelLayout.setHorizontalGroup(
            friendsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(friendsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(friendsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                .addContainerGap())
        );
        friendsPanelLayout.setVerticalGroup(
            friendsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(friendsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(friendsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                .addContainerGap())
        );

        chatBarPanel.setBackground(new java.awt.Color(51, 51, 51));
        chatBarPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        chatBarPanel.setMaximumSize(new java.awt.Dimension(220, 27));
        chatBarPanel.setMinimumSize(new java.awt.Dimension(220, 27));
        chatBarPanel.setPreferredSize(new java.awt.Dimension(220, 27));

        chatBarLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        chatBarLabel.setForeground(new java.awt.Color(255, 255, 255));
        chatBarLabel.setText("Chat");

        minimizeChatButton.setBackground(new java.awt.Color(51, 51, 51));
        minimizeChatButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/minimizeButton.png"))); // NOI18N
        minimizeChatButton.setFocusPainted(false);
        minimizeChatButton.setMaximumSize(new java.awt.Dimension(21, 22));
        minimizeChatButton.setMinimumSize(new java.awt.Dimension(21, 22));
        minimizeChatButton.setPreferredSize(new java.awt.Dimension(21, 22));
        minimizeChatButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/graphics/minimizeButtonPressed.png"))); // NOI18N
        minimizeChatButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minimizeChatButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout chatBarPanelLayout = new javax.swing.GroupLayout(chatBarPanel);
        chatBarPanel.setLayout(chatBarPanelLayout);
        chatBarPanelLayout.setHorizontalGroup(
            chatBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chatBarPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chatBarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)
                .addComponent(minimizeChatButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        chatBarPanelLayout.setVerticalGroup(
            chatBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chatBarPanelLayout.createSequentialGroup()
                .addGroup(chatBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chatBarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(minimizeChatButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        chatPanel.setMaximumSize(new java.awt.Dimension(220, 229));
        chatPanel.setMinimumSize(new java.awt.Dimension(220, 0));
        chatPanel.setPreferredSize(new java.awt.Dimension(220, 194));

        sendButton.setFont(new java.awt.Font("Tahoma", 0, 10));
        sendButton.setText("Send");
        sendButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendButtonActionPerformed(evt);
            }
        });

        inputTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                inputTextFieldKeyPressed(evt);
            }
        });

        outputTextArea.setColumns(20);
        outputTextArea.setEditable(false);
        outputTextArea.setFont(new java.awt.Font("Tahoma", 0, 11));
        outputTextArea.setRows(5);
        jScrollPane2.setViewportView(outputTextArea);

        javax.swing.GroupLayout chatPanelToAdjustLayout = new javax.swing.GroupLayout(chatPanelToAdjust);
        chatPanelToAdjust.setLayout(chatPanelToAdjustLayout);
        chatPanelToAdjustLayout.setHorizontalGroup(
            chatPanelToAdjustLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, chatPanelToAdjustLayout.createSequentialGroup()
                .addGroup(chatPanelToAdjustLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                    .addGroup(chatPanelToAdjustLayout.createSequentialGroup()
                        .addComponent(inputTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sendButton, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)))
                .addContainerGap())
        );
        chatPanelToAdjustLayout.setVerticalGroup(
            chatPanelToAdjustLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, chatPanelToAdjustLayout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(chatPanelToAdjustLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(inputTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sendButton)))
        );

        javax.swing.GroupLayout chatPanelLayout = new javax.swing.GroupLayout(chatPanel);
        chatPanel.setLayout(chatPanelLayout);
        chatPanelLayout.setHorizontalGroup(
            chatPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chatPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chatPanelToAdjust, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        chatPanelLayout.setVerticalGroup(
            chatPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chatPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chatPanelToAdjust, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout rightPanelLayout = new javax.swing.GroupLayout(rightPanel);
        rightPanel.setLayout(rightPanelLayout);
        rightPanelLayout.setHorizontalGroup(
            rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(chatPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(friendsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(quickSearchPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(quickSearchBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(friendsBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(chatBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        rightPanelLayout.setVerticalGroup(
            rightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rightPanelLayout.createSequentialGroup()
                .addComponent(quickSearchBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(quickSearchPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(friendsBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(friendsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chatBarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chatPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout BackgroundPanelLayout = new javax.swing.GroupLayout(BackgroundPanel);
        BackgroundPanel.setLayout(BackgroundPanelLayout);
        BackgroundPanelLayout.setHorizontalGroup(
            BackgroundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, BackgroundPanelLayout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addComponent(mainTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 752, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(BackgroundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(disconnectButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rightPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        BackgroundPanelLayout.setVerticalGroup(
            BackgroundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(BackgroundPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(BackgroundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(mainTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 638, Short.MAX_VALUE)
                    .addGroup(BackgroundPanelLayout.createSequentialGroup()
                        .addComponent(disconnectButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        mainTabbedPane.getAccessibleContext().setAccessibleName("mainTabbedPane");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(BackgroundPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(BackgroundPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void disconnectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disconnectButtonActionPerformed
        // TODO add your handling code here:
        login();
}//GEN-LAST:event_disconnectButtonActionPerformed

    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void quickSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quickSearchButtonActionPerformed
        // TODO add your handling code here:
        initResults();
        if (isLogin || quickSearchNetworkComboBox.getSelectedIndex() == 1) {
            if (quickSearchTextField.getText().length() != 0) {
                mainTabbedPane.setSelectedIndex(3);

                //Faltaría eliminar los resultados o crear una nueva pestaña
                imageLabel.setIcon(null);
                DescriptionContent dc =
                        new grupb.upf.ms.impl.DescriptionContent();
                Object[] parameters = new Object[1];
                parameters[0] =
                        quickSearchTextField.getText().toString().trim();
                advancedSearchTextField.setText(quickSearchTextField.getText().toString().trim());
                String key = "";
                int index = quickSearchTypeComboBox.getSelectedIndex();
                switch (index) {
                    case 0:
                        key = "query.photo.all";
                        photoAdvancedSearchCheckBox.setSelected(true);
                        videoAdvancedSearchCheckBox.setSelected(false);
                        newsAdvancedSearchCheckBox.setSelected(false);
                        break;
                    case 1:
                        key = "query.video.all";
                        photoAdvancedSearchCheckBox.setSelected(false);
                        videoAdvancedSearchCheckBox.setSelected(true);
                        newsAdvancedSearchCheckBox.setSelected(false);
                        break;
                    case 2:
                        key = "query.new.all";
                        photoAdvancedSearchCheckBox.setSelected(false);
                        videoAdvancedSearchCheckBox.setSelected(false);
                        newsAdvancedSearchCheckBox.setSelected(true);
                        break;
                    default:
                        break;
                }
                dc.addProperty("key", key);
                dc.addProperty("parameters", parameters);
                SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
                index = quickSearchNetworkComboBox.getSelectedIndex();
                switch (index) {
                    case 0:
                        controller.sendSearchProfile(sp);
                        friendsNetworkAdvancedSearchCheckBox.setSelected(true);
                        localAdvancedSearchCheckBox.setSelected(false);
                        break;
                    case 1:
                        controller.localSearch(dc);
                        friendsNetworkAdvancedSearchCheckBox.setSelected(false);
                        localAdvancedSearchCheckBox.setSelected(true);
                        break;
                    case 2:
                        controller.sendSearchProfile(sp);
                        controller.localSearch(dc);
                        friendsNetworkAdvancedSearchCheckBox.setSelected(true);
                        localAdvancedSearchCheckBox.setSelected(true);
                        break;
                    default:
                        break;
                }
            }
        } else {
            errorNotLogged();
        }
}//GEN-LAST:event_quickSearchButtonActionPerformed

    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void saveChangesConfigurationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveChangesConfigurationButtonActionPerformed
        // TODO add your handling code here:
        String vlcFolder = vlcFolderTextField.getText().toString().trim();
        if (!vlcFolder.substring(vlcFolder.length() - 1).equals("/")) {
            vlcFolder = vlcFolder + "/";
        }
        grupb.upf.util.Config.setProperty("vlc.folder", vlcFolder);
        grupb.upf.util.Config.setProperty("ip", ipTextField.getText()
                .toString().trim());
        String photoFolder = photoFolderTextField.getText().toString().trim();
        if (!photoFolder.substring(photoFolder.length() - 1).equals("/")) {
            photoFolder = photoFolder + "/";
        }
        grupb.upf.util.Config.setProperty("photo.folder", photoFolder);
        String videoFolder = videoFolderTextField.getText().toString().trim();
        if (!videoFolder.substring(videoFolder.length() - 1).equals("/")) {
            videoFolder = videoFolder + "/";
        }
        grupb.upf.util.Config.setProperty("video.folder", videoFolder);
        photoFolder = photoFolderTextField1.getText().toString().trim();
        if (!photoFolder.substring(photoFolder.length() - 1).equals("/")) {
            photoFolder = photoFolder + "/";
        }
        grupb.upf.util.Config.setProperty("photo.folder.incoming", photoFolder);
        videoFolder = videoFolderTextField1.getText().toString().trim();
        if (!videoFolder.substring(videoFolder.length() - 1).equals("/")) {
            videoFolder = videoFolder + "/";
        }
        grupb.upf.util.Config.setProperty("video.folder.incoming", videoFolder);
        saveProperties();
}//GEN-LAST:event_saveChangesConfigurationButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void advancedSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_advancedSearchButtonActionPerformed
        // TODO add your handling code here:
        String keyword = advancedSearchTextField.getText().trim();
        String searchBy = (String) searchByComboBox.getSelectedItem();
        initResults();
        if (keyword.equalsIgnoreCase("") && !searchBy.equalsIgnoreCase("Date")) {
            addError("You have to set up the keytext to search.");
            return;
        }
        if (!photoAdvancedSearchCheckBox.isSelected() && !videoAdvancedSearchCheckBox.isSelected() && !newsAdvancedSearchCheckBox.isSelected()) {
            addError("You have to select at least one type of file to search.");
            return;
        }
        if (!friendsNetworkAdvancedSearchCheckBox.isSelected() && !localAdvancedSearchCheckBox.isSelected()) {
            addError("You have to select the network");
            return;
        }
        if (isLogin || (!friendsNetworkAdvancedSearchCheckBox.isSelected() && localAdvancedSearchCheckBox.isSelected())) {
            Object[] parameters = null;
            if (typeOfSearchPanel.getSelectedIndex() == 0) {
                //Free search selected
                if (searchBy.equalsIgnoreCase("Date")) {
                    if (yearFromComboBox.getSelectedItem() == null || yearFromComboBox.getSelectedIndex() == 0) {
                        addError("It is necessary to specify at least the year.");
                        return;
                    } else {
                        parameters = new Object[3];
                        int from = (Integer) yearFromComboBox.getSelectedItem() * 10000;
                        int to = ((Integer) yearToComboBox.getSelectedItem() * 10000) + 1232;
                        if (monthFromComboBox.getSelectedItem() != null && monthFromComboBox.getSelectedIndex() != 0) {
                            from = from + ((Integer) monthFromComboBox.getSelectedItem() * 100);
                            to = to - 1200 + ((Integer) monthToComboBox.getSelectedItem() * 100);

                        }
                        if (dayFromComboBox.getSelectedItem() != null && dayFromComboBox.getSelectedIndex() != 0) {
                            from = from + (Integer) dayFromComboBox.getSelectedItem();
                            to = to - 32 + ((Integer) dayToComboBox.getSelectedItem());
                        }
                        parameters[1] = from;
                        parameters[2] = to;
                    }
                } else if (searchBy.equalsIgnoreCase("In a new")) {
                    parameters = new Object[1];
                    String s = (String) advancedPhotoSearchComboBox.getSelectedItem();
                    s = ((s.split(" "))[0]).toLowerCase();
                    StringBuffer sb = new StringBuffer("new.").append(s);
                    searchBy = sb.toString();
                } else {
                    parameters = new Object[1];
                }
            } else {
                searchBy = "intelligent";
                //Intelligent search
                if (categoriesComboBox.getSelectedIndex() < 1) {
                    addError("It's necessary to choose a category.");
                    return;
                }
                boolean keywordExists = false;
                List taxonomy;
                for (int i = 0; i < taxonomies.size(); i++) {
                    taxonomy = (List) taxonomies.get(i);
                    for (int j = 0; j < taxonomy.size(); j++) {
                        if (((String) taxonomy.get(j)).equals(keyword)) {
                            keywordExists = true;
                        }
                    }
                }
                if (!keywordExists) {
                    addError("The Tag doesn't exist in the database.");
                    return;
                }
                parameters = new Object[2];
                parameters[1] = (String) categoriesComboBox.getSelectedItem();
            }
            parameters[0] = keyword;
            DescriptionContent dc =
                    new grupb.upf.ms.impl.DescriptionContent();
            dc.addProperty("parameters", parameters);
            if (photoAdvancedSearchCheckBox.isSelected()) {
                StringBuffer k = new StringBuffer("query.photo.").append(searchBy.toLowerCase());
                String key = k.toString();
                dc.addProperty("key", key);
                if (friendsNetworkAdvancedSearchCheckBox.isSelected()) {
                    SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
                    controller.sendSearchProfile(sp);
                }
                if (localAdvancedSearchCheckBox.isSelected()) {
                    controller.localSearch(dc);
                }
            }
            if (videoAdvancedSearchCheckBox.isSelected()) {
                StringBuffer k = new StringBuffer("query.video.").append(searchBy.toLowerCase());
                String key = k.toString();
                if (!key.startsWith("query.video.new")) {
                    dc.addProperty("key", key);
                    if (friendsNetworkAdvancedSearchCheckBox.isSelected()) {
                        SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
                        controller.sendSearchProfile(sp);
                    }
                    if (localAdvancedSearchCheckBox.isSelected()) {
                        controller.localSearch(dc);
                    }
                }
            }
            if (newsAdvancedSearchCheckBox.isSelected()) {
                StringBuffer k = new StringBuffer("query.new.").append(searchBy.toLowerCase());
                String key = k.toString();
                if (!key.startsWith("query.new.new")) {
                    dc.addProperty("key", key);
                    if (friendsNetworkAdvancedSearchCheckBox.isSelected()) {
                        SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
                        controller.sendSearchProfile(sp);
                    }
                    if (localAdvancedSearchCheckBox.isSelected()) {
                        controller.localSearch(dc);
                    }
                }
            }
        } else {
            errorNotLogged();
        }

}//GEN-LAST:event_advancedSearchButtonActionPerformed

    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void loginGoogleAccountButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginGoogleAccountButtonActionPerformed
        // TODO add your handling code here:
        login();
    }//GEN-LAST:event_loginGoogleAccountButtonActionPerformed

    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        if (isLogin) {
            try {
                controller.logout();
            } catch (Exception e) {
                LOG.error("Error closing", e);
            }
        }   // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosing
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void downloadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadButtonActionPerformed
        // TODO add your handling code here:
        if (searchResultsTable.getSelectedRow() > -1) {
            DescriptionContent dc = results.get(searchResultsTable.getSelectedRow());
            String owner = (String) dc.getProperty("from");
            if (owner.equalsIgnoreCase("me")) {
                if (dc.getProperty("properties") instanceof Photo) {
                    Photo p = (Photo) dc.getProperty("properties");
                    final File f = new File(grupb.upf.util.Config
                            .getProperty("photo.folder") + p.getURL());
                    viewPhoto(f);
                } else if (dc.getProperty("properties") instanceof Video) {
                    Video v = (Video) dc.getProperty("properties");
                    if (grupb.upf.util.Config.getProperty("vlc.folder") == null) {
                        addError("You haven't configured correctly your VLC.");
                    } else {
                        final File f = new File(grupb.upf.util
                                .Config.getProperty("vlc.folder"));
                        final File f2 = new File(grupb.upf.util
                                .Config.getProperty("video.folder"));
                        try {
                            Process a = Runtime.getRuntime().exec("\""
                                    + f.getAbsolutePath()
                                    + "\\vlc\" \"" + f2.getAbsolutePath() +
                                    "\\" + v.getURL()
                                    .replaceAll("/", "\\\\") + "\"");
                        }
                        catch (Exception err) {
                            if (LOG.isFatalEnabled()) {
                                LOG.fatal("Fatal error reproducing the video.",
                                        err);
                                addError("Error reproducing the video");
                            }
                        }
                    }
                } else {
                    viewNew((New) dc.getProperty("properties"));
                }
            } else {
                if (isLogin) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("Asking to download a file...\n");
                    }
                    String to = owner;
                    Object o = dc.getProperty("properties");
                    if (o instanceof Photo) {
                        UserContent uc = new grupb.upf.ms.impl.UserContent(
                                ((Photo) o).getURL());
                        controller.sendUserContent(uc, to);
                    } else if (o instanceof Video) {
                        if (grupb.upf.util.Config.getProperty("vlc.folder")
                                == null || grupb.upf.util.Config.getProperty(
                                "vlc.folder") == null) {
                            addError("You haven't configured correctly your VLC and IP.");
                        } else {
                            UserContent uc = new grupb.upf.ms.impl.UserContent(
                                    ((Video) o).getURL() + ":" + grupb.upf.util
                                    .Config.getProperty("ip"));
                            controller.sendUserContent(uc, to);
                            final File f = new File(grupb.upf.util
                                .Config.getProperty("vlc.folder"));
                            final String ip = (String) dc.getProperty("ip");
                            try {
                                LOG.info("Asking to reproduce the video.");
                                Process a = Runtime.getRuntime()
                                        .exec("\"" +
                                        f.getAbsolutePath() +
                                        "\\vlc\" -vvv udp://@" + ip + ":1234");
                            }
                            catch (Exception err) {
                                if (LOG.isFatalEnabled()) {
                                    LOG.fatal("Fatal error reproducing the video.",
                                            err);
                                    addError("Error reproducing the video");
                                }
                            }
                        }
                    } else if (o instanceof New) {
                        viewNew((New) o);
                    }
                } else {
                    errorNotLogged();
                }
            }
        } else {
            addError("It's necessary to choose a file.");
        }
    }//GEN-LAST:event_downloadButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void minimizeQuickSearchPanelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minimizeQuickSearchPanelButtonActionPerformed
        // TODO add your handling code here:
        if (quickSearchPanelVisible == true) {
            quickSearchPanelVisible = false;
            minimizeQuickSearchPanelButton.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/graphics/maximizeButton.png")));
            minimizeQuickSearchPanelButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource(
                    "/graphics/maximizeButtonPressed.png")));
        } else {
            quickSearchPanelVisible = true;
            minimizeQuickSearchPanelButton.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/graphics/minimizeButton.png")));
            minimizeQuickSearchPanelButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource(
                    "/graphics/minimizeButtonPressed.png")));
        }
        calculateDimensioning();
    }//GEN-LAST:event_minimizeQuickSearchPanelButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void minimizeFriendsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minimizeFriendsButtonActionPerformed
        // TODO add your handling code here:
        if (friendsPanelVisible == true) {
            friendsPanelVisible = false;
            minimizeFriendsButton.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/graphics/maximizeButton.png")));
            minimizeFriendsButton.setPressedIcon(new javax.swing.ImageIcon(
                    getClass().getResource(
                    "/graphics/maximizeButtonPressed.png")));
        } else {
            friendsPanelVisible = true;
            minimizeFriendsButton.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/graphics/minimizeButton.png")));
            minimizeFriendsButton.setPressedIcon(new javax.swing.ImageIcon(
                    getClass().getResource(
                    "/graphics/minimizeButtonPressed.png")));
        }
        calculateDimensioning();
    }//GEN-LAST:event_minimizeFriendsButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void minimizeChatButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minimizeChatButtonActionPerformed
        // TODO add your handling code here:
        if (chatPanelVisible == true) {
            chatPanelVisible = false;
            minimizeChatButton.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/graphics/maximizeButton.png")));
            minimizeChatButton.setPressedIcon(new javax.swing.ImageIcon(
                    getClass().getResource(
                    "/graphics/maximizeButtonPressed.png")));
        } else {
            chatPanelVisible = true;
            minimizeChatButton.setIcon(new javax.swing.ImageIcon(
                    getClass().getResource("/graphics/minimizeButton.png")));
            minimizeChatButton.setPressedIcon(new javax.swing.ImageIcon(
                    getClass().getResource(
                    "/graphics/minimizeButtonPressed.png")));
        }
        calculateDimensioning();
}//GEN-LAST:event_minimizeChatButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void friendsListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_friendsListMouseClicked
        // TODO add your handling code here:
        if (SwingUtilities.isRightMouseButton(evt) && !friendsList.isSelectionEmpty() && friendsList.locationToIndex(evt.getPoint()) == friendsList.getSelectedIndex()) {
            friendsPopupMenu.show(friendsList, evt.getX(), evt.getY());
        } else if (evt.getClickCount() == 2) {
            openInstantMessageFrame();
        }
    }//GEN-LAST:event_friendsListMouseClicked
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void sendMessageMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendMessageMenuItemActionPerformed
        // TODO add your handling code here:
        openInstantMessageFrame();
    }//GEN-LAST:event_sendMessageMenuItemActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void passwordGoogleAccountPasswordFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_passwordGoogleAccountPasswordFieldFocusGained
        // TODO add your handling code here:
        passwordGoogleAccountPasswordField.selectAll();
    }//GEN-LAST:event_passwordGoogleAccountPasswordFieldFocusGained
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void passwordGoogleAccountPasswordFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_passwordGoogleAccountPasswordFieldKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
            login();
        }
    }//GEN-LAST:event_passwordGoogleAccountPasswordFieldKeyPressed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void videoFolderBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videoFolderBrowseButtonActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File f = fc.getSelectedFile();
            videoFolderTextField.setText(f.getAbsolutePath().replaceAll("\\\\", "/"));
        }
}//GEN-LAST:event_videoFolderBrowseButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void inputTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputTextFieldKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
            sendMessage();
        }
    }//GEN-LAST:event_inputTextFieldKeyPressed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
        // TODO add your handling code here:
        sendMessage();
    }//GEN-LAST:event_sendButtonActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void viewPhotosMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewPhotosMenuItemActionPerformed
        // TODO add your handling code here:
        initResults();
        results.clear();
        String to = friendsList.getSelectedValue().toString();
        DescriptionContent dc =
                new grupb.upf.ms.impl.DescriptionContent();
        String key = "query.photo";
        SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
        dc.addProperty("key", key);
        controller.sendSearchProfile(sp, to);
        mainTabbedPane.setSelectedIndex(3);
    }//GEN-LAST:event_viewPhotosMenuItemActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void viewVideosMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewVideosMenuItemActionPerformed
        // TODO add your handling code here:
        initResults();
        results.clear();
        String to = friendsList.getSelectedValue().toString();
        DescriptionContent dc =
                new grupb.upf.ms.impl.DescriptionContent();
        String key = "query.video";
        SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
        dc.addProperty("key", key);
        controller.sendSearchProfile(sp, to);
        mainTabbedPane.setSelectedIndex(3);
    }//GEN-LAST:event_viewVideosMenuItemActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void viewNewsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewNewsMenuItemActionPerformed
        // TODO add your handling code here:
        initResults();
        String to = friendsList.getSelectedValue().toString();
        DescriptionContent dc =
                new grupb.upf.ms.impl.DescriptionContent();
        String key = "query.new";
        SearchProfile sp = new grupb.upf.ms.impl.SearchProfile(dc);
        dc.addProperty("key", key);
        controller.sendSearchProfile(sp, to);
        mainTabbedPane.setSelectedIndex(3);
    }//GEN-LAST:event_viewNewsMenuItemActionPerformed
    /**
     * It contains the actions to do when this button is clicked.
     * @param evt the event received
     */
    private void photoAdvancedSearchCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_photoAdvancedSearchCheckBoxItemStateChanged
        // TODO add your handling code here:
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            searchByComboBox.addItem("In a new");
        } else {
            if (((String) searchByComboBox.getItemAt(searchByComboBox.getItemCount() - 1)).equalsIgnoreCase("In a new")) {
                searchByComboBox.removeItemAt(
                        searchByComboBox.getItemCount() - 1);
            }
        }
    }//GEN-LAST:event_photoAdvancedSearchCheckBoxItemStateChanged

    private void searchByComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_searchByComboBoxItemStateChanged
        // TODO add your handling code here:
        if (((String) searchByComboBox.getSelectedItem()).equalsIgnoreCase("Date")) {
            datePanel.setVisible(true);
            addYearsFrom();
            yearFromComboBox.setSelectedIndex(1);
        } else {
            datePanel.setVisible(false);
        }
        if (((String) searchByComboBox.getSelectedItem()).equalsIgnoreCase("In a new")) {
            advancedPhotoSearchComboBox.setVisible(true);
            newFiltersLabel.setVisible(true);
        } else {
            advancedPhotoSearchComboBox.setVisible(false);
            newFiltersLabel.setVisible(false);
        }
}//GEN-LAST:event_searchByComboBoxItemStateChanged

    private void yearFromComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_yearFromComboBoxItemStateChanged
        // TODO add your handling code here:
        if (yearFromComboBox.getSelectedIndex() == 0) {
            yearToComboBox.removeAllItems();
            yearToComboBox.addItem("yyyy");
            yearToComboBox.setEnabled(false);
            monthFromComboBox.removeAllItems();
            monthFromComboBox.addItem("mm");
            monthFromComboBox.setEnabled(false);
            monthToComboBox.removeAllItems();
            monthToComboBox.addItem("mm");
            monthToComboBox.setEnabled(false);
            dayFromComboBox.removeAllItems();
            dayFromComboBox.addItem("dd");
            dayFromComboBox.setEnabled(false);
            dayToComboBox.removeAllItems();
            dayToComboBox.addItem("dd");
            dayToComboBox.setEnabled(false);

        } else if (yearFromComboBox.getSelectedItem() != null) {
            final int selectedYear =
                    (Integer) yearFromComboBox.getSelectedItem();
            addYearsTo(selectedYear);
            addMonthsFrom(selectedYear);
        }
}//GEN-LAST:event_yearFromComboBoxItemStateChanged

    private void monthFromComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_monthFromComboBoxItemStateChanged
        // TODO add your handling code here:
        if (monthFromComboBox.getSelectedIndex() == 0) {
            monthToComboBox.removeAllItems();
            monthToComboBox.addItem("mm");
            monthToComboBox.setEnabled(false);
            dayFromComboBox.removeAllItems();
            dayFromComboBox.addItem("dd");
            dayFromComboBox.setEnabled(false);
            dayToComboBox.removeAllItems();
            dayToComboBox.addItem("dd");
            dayToComboBox.setEnabled(false);

        } else if (monthFromComboBox.getSelectedItem() != null) {
            final int selectedYearTo =
                    (Integer) yearToComboBox.getSelectedItem();
            final int selectedYear =
                    (Integer) yearFromComboBox.getSelectedItem();
            final int selectedMonth =
                    (Integer) monthFromComboBox.getSelectedItem();
            addMonthsTo(selectedYearTo, selectedYear, selectedMonth);
            addDaysFrom(selectedYear, selectedMonth);
        }
}//GEN-LAST:event_monthFromComboBoxItemStateChanged

    private void dayFromComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_dayFromComboBoxItemStateChanged
        // TODO add your handling code here:
        if (dayFromComboBox.getSelectedIndex() == 0) {
            dayToComboBox.removeAllItems();
            dayToComboBox.addItem("dd");
            dayToComboBox.setEnabled(false);

        } else if (dayFromComboBox.getSelectedItem() != null) {
            final int selectedYearTo =
                    (Integer) yearToComboBox.getSelectedItem();
            final int selectedYear =
                    (Integer) yearFromComboBox.getSelectedItem();
            final int selectedMonthTo =
                    (Integer) monthToComboBox.getSelectedItem();
            final int selectedMonth =
                    (Integer) monthFromComboBox.getSelectedItem();
            final int selectedDay =
                    (Integer) dayFromComboBox.getSelectedItem();
            addDaysTo(selectedYearTo, selectedYear, selectedMonthTo,
                    selectedMonth, selectedDay);
        }
}//GEN-LAST:event_dayFromComboBoxItemStateChanged

    private void yearToComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_yearToComboBoxItemStateChanged
        // TODO add your handling code here:
        if (monthFromComboBox.isEnabled() && yearToComboBox.getSelectedItem() != null && yearFromComboBox.getSelectedItem() != null && monthFromComboBox.getSelectedItem() != null && yearFromComboBox.getSelectedIndex() != 0 && monthFromComboBox.getSelectedIndex() != 0) {
            final int selectedYearTo =
                    (Integer) yearToComboBox.getSelectedItem();
            final int selectedYear =
                    (Integer) yearFromComboBox.getSelectedItem();
            final int selectedMonth =
                    (Integer) monthFromComboBox.getSelectedItem();
            addMonthsTo(selectedYearTo, selectedYear, selectedMonth);
        }
}//GEN-LAST:event_yearToComboBoxItemStateChanged

    private void monthToComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_monthToComboBoxItemStateChanged
        // TODO add your handling code here:
        if (dayFromComboBox.isEnabled() && yearToComboBox.getSelectedItem() != null && yearFromComboBox.getSelectedItem() != null && monthToComboBox.getSelectedItem() != null && monthFromComboBox.getSelectedItem() != null && dayFromComboBox.getSelectedItem() != null && yearFromComboBox.getSelectedIndex() != 0 && monthFromComboBox.getSelectedIndex() != 0 && dayFromComboBox.getSelectedIndex() != 0) {
            final int selectedYearTo =
                    (Integer) yearToComboBox.getSelectedItem();
            final int selectedYear =
                    (Integer) yearFromComboBox.getSelectedItem();
            final int selectedMonthTo =
                    (Integer) monthToComboBox.getSelectedItem();
            final int selectedMonth =
                    (Integer) monthFromComboBox.getSelectedItem();
            final int selectedDay =
                    (Integer) dayFromComboBox.getSelectedItem();
            addDaysTo(selectedYearTo, selectedYear, selectedMonthTo,
                    selectedMonth, selectedDay);
        }
}//GEN-LAST:event_monthToComboBoxItemStateChanged

    private void typeOfSearchPanelStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_typeOfSearchPanelStateChanged
        // TODO add your handling code here:
        if (typeOfSearchPanel.getSelectedIndex() == 1) {
            advancedSearchTextField.setEnabled(false);
            advancedSearchTextField.setText("Choose a category");
        } else {
            advancedSearchTextField.setEnabled(true);
            advancedSearchTextField.setText("");
        }
    }//GEN-LAST:event_typeOfSearchPanelStateChanged

    private void categoriesComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_categoriesComboBoxItemStateChanged
        // TODO add your handling code here:
        if (typeOfSearchPanel.getSelectedIndex() == 1) {
            if (categoriesComboBox.getSelectedIndex() > 0) {
                advancedSearchTextField.setEnabled(true);
                advancedSearchTextField.setText("");
            } else {
                advancedSearchTextField.setEnabled(false);
                advancedSearchTextField.setText("Choose a category");
            }
        }
    }//GEN-LAST:event_categoriesComboBoxItemStateChanged

    private void advancedSearchTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_advancedSearchTextFieldKeyReleased
        // TODO add your handling code here:
        if (typeOfSearchPanel.getSelectedIndex() == 1) {
            String text = advancedSearchTextField.getText();
            List tax = (List) taxonomies.get(categoriesComboBox.getSelectedIndex() - 1);
            Collections.sort(tax);
            ontologiesPopupMenu = new javax.swing.JPopupMenu();
            for (int i = 1; i < tax.size(); i++) {
                if (((String) tax.get(i)).toLowerCase().startsWith(
                        text.toLowerCase())) {
                    final javax.swing.JMenuItem item =
                            new javax.swing.JMenuItem(
                            (String) tax.get(i));
                    item.addActionListener(
                            new java.awt.event.ActionListener() {

                                @Override
                                public void actionPerformed(
                                        java.awt.event.ActionEvent e) {
                                    advancedSearchTextField.setText(item.getText());
                                }
                            });
                    ontologiesPopupMenu.add(item);
                }
            }
            ontologiesPopupMenu.show(advancedSearchTextField,
                    advancedSearchTextField.getX() - 5,
                    advancedSearchTextField.getY() + 10);
            advancedSearchTextField.grabFocus();
        }
    }//GEN-LAST:event_advancedSearchTextFieldKeyReleased

    private void photoFolderBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_photoFolderBrowseButtonActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File f = fc.getSelectedFile();
            photoFolderTextField.setText(f.getAbsolutePath().replaceAll("\\\\", "/"));
        }
}//GEN-LAST:event_photoFolderBrowseButtonActionPerformed

    private void photoFolderBrowseButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_photoFolderBrowseButton1ActionPerformed
        // TODO add your handling code here:
        FileSystemView fsv = new FileChooser(
                new File(photoFolderTextField.getText()).getAbsoluteFile());
        JFileChooser fc = new JFileChooser(fsv);
        fc.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File f = fc.getSelectedFile();
            photoFolderTextField1.setText(f.getAbsolutePath().replaceAll("\\\\", "/"));
        }
    }//GEN-LAST:event_photoFolderBrowseButton1ActionPerformed

    private void videoFolderBrowseButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videoFolderBrowseButton1ActionPerformed
        // TODO add your handling code here:
        FileSystemView fsv = new FileChooser(
                new File(videoFolderTextField.getText()).getAbsoluteFile());
        JFileChooser fc = new JFileChooser(fsv);
        fc.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File f = fc.getSelectedFile();
            videoFolderTextField1.setText(f.getAbsolutePath().replaceAll("\\\\", "/"));
        }
    }//GEN-LAST:event_videoFolderBrowseButton1ActionPerformed

    private void vlcFolderBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vlcFolderBrowseButtonActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File f = fc.getSelectedFile();
            vlcFolderTextField.setText(f.getAbsolutePath().replaceAll("\\\\", "/"));
        }
}//GEN-LAST:event_vlcFolderBrowseButtonActionPerformed

    private void deleteNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteNewButtonActionPerformed
        // TODO add your handling code here:
        if (newsTable.getSelectedRow() != -1) {
            deleteDialog.setVisible(true);
            deleteDialog.setLocation(400, 250);
        } else {
            addWarning("You have to select a new to delete!");
        }
    }//GEN-LAST:event_deleteNewButtonActionPerformed

    private void editNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editNewButtonActionPerformed
        // TODO add your handling code here:
        if (newsTable.getSelectedRow() != -1) {
            final int index = newsTable
                            .convertRowIndexToModel(
                            newsTable.getSelectedRow());
            viewNewsEdition(newsTableModel.getNew(index));
            
        } else {
            addWarning("You have to select a new to edit!");
        }
    }//GEN-LAST:event_editNewButtonActionPerformed

    private void addNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addNewButtonActionPerformed
        // TODO add your handling code here:
        viewNewsEdition(null);
    }//GEN-LAST:event_addNewButtonActionPerformed

    private void deleteNoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteNoButtonActionPerformed
        // TODO add your handling code here:
        deleteDialog.setVisible(false);
}//GEN-LAST:event_deleteNoButtonActionPerformed

    private void deleteYesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteYesButtonActionPerformed
        // TODO add your handling code here:
        deleteDialog.setVisible(false);
        deleteNew();
        initNews();
        this.repaint();
}//GEN-LAST:event_deleteYesButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel BackgroundPanel;
    private javax.swing.JButton addNewButton;
    private javax.swing.JComboBox advancedPhotoSearchComboBox;
    private javax.swing.JButton advancedSearchButton;
    private javax.swing.JPanel advancedSearchOptionsPanel;
    private javax.swing.JPanel advancedSearchPanel;
    private javax.swing.JTextField advancedSearchTextField;
    private javax.swing.JLabel applicationFolderLabel;
    private javax.swing.JLabel applicationFolderLabel1;
    private javax.swing.JComboBox categoriesComboBox;
    private javax.swing.JLabel categoriesLabel;
    private javax.swing.JLabel chatBarLabel;
    private javax.swing.JPanel chatBarPanel;
    private javax.swing.JPanel chatPanel;
    private javax.swing.JPanel chatPanelToAdjust;
    private javax.swing.JPanel configurationPanel;
    private javax.swing.JLabel dateFromLabel;
    private javax.swing.JPanel datePanel;
    private javax.swing.JLabel dateToLabel;
    private javax.swing.JComboBox dayFromComboBox;
    private javax.swing.JComboBox dayToComboBox;
    private javax.swing.JDialog deleteDialog;
    private javax.swing.JButton deleteNewButton;
    private javax.swing.JButton deleteNoButton;
    private javax.swing.JButton deleteYesButton;
    private javax.swing.JButton disconnectButton;
    private javax.swing.JButton downloadButton;
    private javax.swing.JButton editNewButton;
    private javax.swing.JPanel freeSearchPanel;
    private javax.swing.JLabel friendsBarLabel;
    private javax.swing.JPanel friendsBarPanel;
    private javax.swing.JList friendsList;
    private javax.swing.JCheckBox friendsNetworkAdvancedSearchCheckBox;
    private javax.swing.JPanel friendsPanel;
    private javax.swing.JPopupMenu friendsPopupMenu;
    private javax.swing.JScrollPane friendsScrollPane;
    private javax.swing.JLabel generalFoldersLabel;
    private javax.swing.JLabel googleAccountLabel;
    private javax.swing.JPanel googleAccountPanel;
    private javax.swing.JLabel imageLabel;
    private javax.swing.JLabel incomingFoldersLabel;
    private javax.swing.JTextField inputTextField;
    private javax.swing.JPanel intelligentSearchPanel;
    private javax.swing.JTextField ipTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JCheckBox localAdvancedSearchCheckBox;
    private javax.swing.JButton loginGoogleAccountButton;
    private javax.swing.JTabbedPane mainTabbedPane;
    private javax.swing.JButton minimizeChatButton;
    private javax.swing.JButton minimizeFriendsButton;
    private javax.swing.JButton minimizeQuickSearchPanelButton;
    private javax.swing.JComboBox monthFromComboBox;
    private javax.swing.JComboBox monthToComboBox;
    private javax.swing.JLabel nameGoogleAccountLabel;
    private javax.swing.JTextField nameGoogleAccountTextField;
    private javax.swing.JLabel newFiltersLabel;
    private javax.swing.JCheckBox newsAdvancedSearchCheckBox;
    private javax.swing.JPanel newsListPanel;
    private javax.swing.JPanel newsManagerPanel;
    private javax.swing.JPanel newsPanel;
    private javax.swing.JTable newsTable;
    private javax.swing.JLabel noteLabel;
    private javax.swing.JPopupMenu ontologiesPopupMenu;
    private javax.swing.JPanel optionsPanel;
    private javax.swing.JPanel otherFeaturesPanel;
    private javax.swing.JTextArea outputTextArea;
    private javax.swing.JLabel passwordGoogleAccountLabel;
    private javax.swing.JPasswordField passwordGoogleAccountPasswordField;
    private javax.swing.JCheckBox photoAdvancedSearchCheckBox;
    private javax.swing.JButton photoFolderBrowseButton;
    private javax.swing.JButton photoFolderBrowseButton1;
    private javax.swing.JLabel photoFolderLabel;
    private javax.swing.JLabel photoFolderLabel1;
    private javax.swing.JTextField photoFolderTextField;
    private javax.swing.JTextField photoFolderTextField1;
    private javax.swing.JPanel photoPanel;
    private javax.swing.JTabbedPane photosDirectoriesTabbedPane;
    private javax.swing.JPanel photosPanel;
    private javax.swing.JLabel picasaLabel2;
    private javax.swing.JLabel quickSearchBarLabel;
    private javax.swing.JPanel quickSearchBarPanel;
    private javax.swing.JButton quickSearchButton;
    private javax.swing.JComboBox quickSearchNetworkComboBox;
    private javax.swing.JLabel quickSearchNetworkLabel;
    private javax.swing.JPanel quickSearchPanel;
    private javax.swing.JTextField quickSearchTextField;
    private javax.swing.JComboBox quickSearchTypeComboBox;
    private javax.swing.JLabel quickSearchTypeLabel;
    private javax.swing.JCheckBox rememberGoogleAccountCheckBox;
    private javax.swing.JPanel resultsHeadPanel;
    private javax.swing.JScrollPane resultsScrollPane;
    private javax.swing.JPanel rightPanel;
    private javax.swing.JButton saveChangesConfigurationButton;
    private javax.swing.JComboBox searchByComboBox;
    private javax.swing.JLabel searchByLabel;
    private javax.swing.JPanel searchByPanel;
    private javax.swing.JLabel searchNetwork;
    private javax.swing.JLabel searchNetwork1;
    private javax.swing.JPanel searchPanel;
    private javax.swing.JTable searchResultsTable;
    private javax.swing.JButton sendButton;
    private javax.swing.JMenuItem sendMessageMenuItem;
    private javax.swing.JTabbedPane typeOfSearchPanel;
    private javax.swing.JLabel videSettingsLabel;
    private javax.swing.JCheckBox videoAdvancedSearchCheckBox;
    private javax.swing.JButton videoFolderBrowseButton;
    private javax.swing.JButton videoFolderBrowseButton1;
    private javax.swing.JTextField videoFolderTextField;
    private javax.swing.JTextField videoFolderTextField1;
    private javax.swing.JPanel videoPanel;
    private javax.swing.JPanel videoSettingsPanel;
    private javax.swing.JPanel videoTreePanel;
    private javax.swing.JPanel videosPanel;
    private javax.swing.JMenuItem viewNewsMenuItem;
    private javax.swing.JMenuItem viewPhotosMenuItem;
    private javax.swing.JMenuItem viewVideosMenuItem;
    private javax.swing.JButton vlcFolderBrowseButton;
    private javax.swing.JTextField vlcFolderTextField;
    private javax.swing.JComboBox yearFromComboBox;
    private javax.swing.JComboBox yearToComboBox;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
